Style Last eliment of dynamic html element list using CSS


This is called as CSS3 :last-child Selector

This  Will select last html element in  certain css class.

As an example think your php application will echo you nth number of div in php page.
Some times it may be 10 divs/ 5 divs or only 3 divs. But they may draw automatically in some scenarios. If you want to high light final div of them with special background color you can use   CSS3 :last-child Selector to do that.


Specify a background color for the <p> element that is the last child of its parent:

div:last-child {
    background: #0000ff;
} 



Result will like
The first paragraph.
The second paragraph.
The third paragraph.
The fourth paragraph.
Share on Google Plus

About srimaster

Tech Dropper is simple, easy and newest technology source with experiments and demos. I will give you tutorials, notes, code snippets, demos using PHP, MySQL, jQuery, HTML, CSS, Ajax and Javascripts.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment