How to select an element using its ID without the high specificity of the ID selector?
August 23, 2020

If we use an attribute selector to select an element by its ID then it will have a lower level of specificity than if it was selected with an ID selector. 

For e.g. We can target the same element with [id="ID_name"] and #ID_name but with lower specificity.


<div id="ID_name">...</div> 


#ID_name { ... } /* High specificity */

[id="ID_name"] { ... } /* Low specificity */

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 5 How to create flickering text using CSS? Mar 4 How to use data-* Attributes in HTML? Mar 4 The substr() method in JavaScript and how it’s different from substring() Mar 4 A complete guide to add responsive YouTube videos using HTML and CSS Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress?

You might also like these

The order Property in Flex Items in CSSCSSCSS Attribute SelectorsCSSWhat is the best way to add JavaScript Code into HTML?HTMLKilling A Project Part 2: Who should make the decision to kill a project?MiscAngular 9 time clock update every minute, second, hourAngularHow to remove N/A from Radio Button list in Drupal?Drupaltransform-origin Property in CSSCSSHow to import MySQL small sample database into phpMySQL?SQL/MySQLHow to Use ROLLUP Operator in SQL and MySQL?SQL/MySQLOOP, Class and Objects Strategies For Beginners (PHP)PHPHow to Install PHP Laravel in MacOS Catalina?PHPHow to check if radio button is checked or not using JavaScript?JavaScript