Css:-Last child


The last-child selector matches every element that is the last child of its parent.





<!DOCTYPE html> 
<html> 
 
<head> 
 <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
 <style> 
  div:last-child { 
   background-color: red; 
   color: white; 
  } 
 </style> 
 
</head> 
 
<body> 
 
 <div>This is the First Div</div> 
 <div>This is the Second Div</div> 
 <div>This is the Third Div</div> 
 <div>This is the Fourth Div</div> 
 <div>This is the Fifth Div</div> 
 <div>This is the Sixth Div</div> 
 <div>This is the Seventh Div</div> 
 
</body> 
 
</html>


Output:-  


This is the First Div
This is the Second Div
This is the Third Div
This is the Fourth Div
This is the Fifth Div
This is the Sixth Div
This is the Seventh Div
Css:-Last child Css:-Last child Reviewed by Network security on May 12, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.