recitation5 notes

But then of the remaining selectors only h1title

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: through t1 and t2 one index at a time. If at any point, t1's value at that index is greater than t2's, then return: s1 is the more specific selector. If t1's value at that index is equal to t2's value, then iterate to the next index. For example, given the selectors above (p, h1, #title, h1#title, h1#title p, and h1#title p.intro), first we can weed out p and h1 since they have no ids specified in their selector, but all the other selectors have 1 id specified. But then of the remaining selectors, only h1#title p.intro has a class specified, so it is the most specific selector. So who wins here? h1 p.intro {color: red;} � (0, 1, 2) #title p {color: blue;} � (1, 0, 1) Yeah. #title p. IDs are very "powerful" when it comes to specificity - use them sparingly. You should rarely have a reason to use an ID, and you should use classes almost always. 4. Break any remaining ties with the declaration declared most "recently" (bottom of the CSS file). So if in a particular stylesheet you have the following rules: h1 {color: blue;} h1 {color: red;} The second rule trumps over the 1st since it was declared more "recently". It's analogous to doing x=1 x=2 in a programming language. Asset tag helpers provide methods for generating HTML that link views to stylesheets. Stylesheets is one of the six asset tag helpers available in Rails: • auto_discovery_link_tag • javascript_include_tag • stylesheet_link_tag • image_tag • video_tag • audio_tag If you have two separate author stylesheets that both have a rule targeting the same <link rel="stylesheet" type="text/css" href="css/whale1.css" /> <link rel="stylesheet" type="text/css" href="css/whale2.css" /> Then the rule declared in whale2.css wins. So within a stylesheet, the last declared rule wins. Among different stylesheets of the same origin, the rule in the last linked stylesheet wins. Although these ru...
View Full Document

This document was uploaded on 03/18/2014 for the course EECS 6.170 at MIT.

Ask a homework question - tutors are online