CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.
I have noticed in stylesheets that people target many different selectors like this
div#content ul li
but when they target links they seperate with commas
a:link, a:hover, a:active
why the commas?
This reply has been reported for inappropriate content.
when there is no commas it will apply that style to the child in that exact order of coding. so for your example it will apply it to a list item in an unordered list within a div with id=content.
so the style will only be applied to the <li> tag, but the <p> tag will not have this style applied
The commas serve to break the reading of the css so the same style can be applied to multiple tags with only one statement. So in your example a:link and a:hover and a:active will have the same style.
I think Adam had a pretty good explanation. In short, a comma separates two entirely different selectors. We just use them so we don’t have to write the same attributes twice.
You must be logged in to reply to this topic.
Search for Stuff
Browse the Archives
Get the Newsletter
... or get the RSS feed