- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The:last-child selector not working as expected in HTML5
The last-child selector is used to select the last child element of a parent. It cannot be used to select the last child element with a specific class under a given parent element.
Style the last child li element with background-color −
li:last-child{ background-color: blue; }
It creates issues if the element is not the very last element.
Let us see an example of <a> −
If your selector is a:last-child, this works −
<div> <a></a> <a>This will be selected</a> </div>
- Related Articles
- Order by multiple columns not working as expected in MySQL?
- canvas.style.display = “block” not working in HTML5
- HTML5 tag not working in Android Webview
- HTML5 meta name = “viewport” doesn't work as expected
- CSS Child Selector
- jQuery :first-child Selector
- jQuery :last-child Selector
- jQuery :nth-child() Selector
- jQuery :only-child Selector
- jQuery parent > child Selector
- jQuery :nth-last-child() Selector
- HTML5 video not working with jquery bxSlider plugin on iPad
- Role of CSS: first-child Selector
- Role of CSS :last-child Selector
- Role of CSS :only-child Selector

Advertisements