Home arrow Style Sheets arrow Page 5 - Double Vision – Give the Browsers CSS They Can Digest

Double Vision – Give the Browsers CSS They Can Digest

Some but not all browsers support CSS2. You can deliberately code your website so that users of either kind of browser will see pages that are appropriate for what their browser can handle. Older browsers won't gag, but you will still be able to take advantage of what you can do with CSS2 in the newer browsers. Read on to find out how.

Author Info:
By: Chris Heilmann
Rating: 5 stars5 stars5 stars5 stars5 stars / 15
February 22, 2005
  1. · Double Vision – Give the Browsers CSS They Can Digest
  2. · The way of the dark side – code forking
  3. · The way of confusion – browser hacks
  4. · The way into the future – progressive enhancement
  5. · The child selector
  6. · Enhancing with the child selector
  7. · The screen display style sheet
  8. · The print style sheet

print this article

Double Vision – Give the Browsers CSS They Can Digest - The child selector
(Page 5 of 8 )

It is pretty hard finding useful examples for the child selector, but basically it can save some hassle, for example in the following HTML:


<p>Content 1</p>


    <li><p>Content 2</p></li>

    <li><p>Content 3</p></li>


<p>Content 2</p>



We want all the P elements outside the list to have a background, but the ones inside the list to have none.


What we could use is: 

div p{background:#036;}

div li p{background:transparent;}

which can be replaced on real CSS2 browsers with:




Adjacent sibling selectors

These selectors allow us to match exactly the next element in the node tree. For example, they allow us to only apply a margin to a paragraph when it is not following another paragraph. If it does follow another paragraph, we won’t apply a margin, but indent the text – much like you do in books: 

p {margin:.5em 0 0 0;}

p+p {margin:0;text-indent:1em;} 

blog comments powered by Disqus

- CSS Padding Overview
- CSS: Margins Overview
- Top CSS3 Button Tutorials
- More Top CSS3 Tutorials for Animation and Im...
- CSS Mega Menus: Adding Extra Sections
- CSS Mega Menus
- CSS3 Accordian Menu: Horizontally Display Hy...
- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials