Among the kinds of CSS selectors, a single which is often overlooked is the CSS Adjacent Selector.
Adjacent sibling selectors possess the subsequent syntax: E1 + E2, where E2 will be the subject matter of your selector. The selector matches if E1 and E2 reveal exactly the same parent in the document tree and E1 instantly precedes E2.
The CSS code
h4 + p font-weight: bold; color: #000;
The text below is actually a simple example with the over code:
That is standard heading 4 text
This will be the <p> after the heading. It should be daring and black.
What’s even better is that this seems to work perfectly in IE 7 (UPDATE: it seems that this does not work in IE6,
Microsoft Office 2010 Product Key, so it is going to be a bit before that is usable on any large scale. However, it is still good to understand these obscure CSS selectors because you might come across them as a professional, especially if IE8 successfully puts IE6 out from the top 5 browsers), Firefox,
Office 2010 Professional Microsoft Office 2010 Portable Black Edition with Key l, Opera, and Safari. Now I know what you’re thinking. Exactly where in the world am I going to use this?
Perhaps we could use something like this to do something to all rows in a table except the first row? What if we knew the next element after an <img> tag was going to be a custom caption that we wanted to place properly underneath our image? The only problem I see is that this couples the HTML and CSS more than we might like sometimes. However, there are many places that probably would benefit from something this simple. Simplicity rules. Now that you know how to use it I have every confidence you can come up with a brilliant use for it.
What ideas do you have to use this CSS gem? What other selectors have you found useful but don’t often see?