This post originated from an RSS feed registered with Web Buzz
by Lee v.
Original Post: CSS :first-child - Definition and Usage
Feed Title: IT Jungles
Feed URL: http://www.itjungles.com/rss
Feed Description: Learn all tech stuff at ITJungles.com
Latest Web Buzz Posts
Latest Web Buzz Posts by Lee v
Latest Posts From IT Jungles
Advertisement
The :first-child selector is used to select the specified selector, only if it is the first child of its parent.
Example:
- Select and style the first child element of every <ul> element:
ul>:first-child { background:#A40003; }
- Select and style the first <li> element in lists:
li:first-child {background:#000;}
- Select and style every <p> element that is the first child of its parent:
p:first-child { background-color:#999;}
The :first-child selector is supported in all major browsers.
Note: For :first-child to work in IE8 and earlier, a <!DOCTYPE> must be declared.
Did you like this tip? {fblike}
Read: CSS :first-child - Definition and Usage