August 20, 200917 yr I am trying to style an existing template. I have the following code: <li class="even"> <div class="clr"> </li> I would like to style the 'clr' class but only when it occurs inside the list class "even". Could someone explain how I do this? Thank you in advance.
August 20, 200917 yr li.even .clr { color: red; } This will make all text red for any element with a .clr class that's within a listitem ( LI ) with an .even class.
August 20, 200917 yr this applies to everything. For example, if you wanted to syle all the spans with and id of "blue", but only if theyre inside an anchor tag with class of "red", and only then if the body tag is id'd "home", it would look like this: body#home a.red span#blue{ /*--Styling--*/ } That's why they call 'em "cascading" style sheets.
August 23, 200917 yr Hello, If we talk in semantic a div inside a li isn't correct. For that you use span. Best Regards
August 23, 200917 yr Hello, If we talk in semantic a div inside a li isn't correct. For that you use span. Best Regards divs and spans have no semantic meaning. The only difference is that one is a block and one is in-line. li elements allow flow content - which means inline and block. http://www.w3.org/TR/html4/struct/lists.html#h-10.2 Nothing wrong with div inside a li.
August 23, 200917 yr Hello, Dear Thomas Thomassen tks for correcting me, I thought it was only inline elements. Sorry for the mistake. Best Regards.
Create an account or sign in to comment