HTML and CSS Reference
In-Depth Information
applied to link elements ( a ) and only IE8 accepts the :active state on
elements other than links.
The :first-child pseudo-class allows you to target an element that is
the first child of another element. For example, if you want to add a top
margin to the first li element of your unordered lists, you can have this:
ul > li:first-child {
margin-top: 10px;
Let's take another example: you want all your h2 tags in your sidebar to
have a top margin, to separate them from whatever comes before them, but
the first one doesn't need a margin. You can use the following code:
#sidebar > h2 {
margin-top: 10px;
#sidebar > h2:first-child {
margin-top: 0;
Notes on browser support
IE6 doesn't support the :first-child pseudo-class. Depending on the
design that the pseudo-class is being applied to, it may not be a major cause
for concern. For example, if you are using the :first-child selector to
remove top or bottom margins from headings or paragraphs, your layout will
probably not break in IE6, it will only look sightly di " erent. But if you are
using the :first-child selector to remove left and right margins from, for
example, a floated sequence of div s, that may cause more disruption to
your designs.
Search WWH ::

Custom Search