DEV Community

Cover image for Css Selectors By Attribute with 3 Examples
Shan Asif
Shan Asif

Posted on • Edited on

Css Selectors By Attribute with 3 Examples

What is an Attribute selector in CSS?

An attribute selector matches a tag based on the value of its attribute. In other words, it's used to select elements that have a particular attribute.

Understand Css Selectors By Attribute with examples:

Example # 1:

Select all the elements with an href matching "example.org"

a[href="example.org"] {...}

Example # 2:

Select elements with an href containing "example"

a[href*="example"] {... }

Example # 3:

Elements that have been set to display: none or visibility='hidden' by default

a[visibility=hidden] {...}

Don't stop here! I have another great guide for you.

You can now read our CSS Selectors cheat sheet for free

Learning CSS box-shadows could be difficult?

Css Selectors By Attribute with 3 Examples

You do not need to worry at all.

Because I have also created a complete 101 guide about CSS box-shadow with several different real-world examples and output.

You will definitely love it.

Don't forget to follow my profile here for more cool & instant stuff in web development.

Best of luck!

Top comments (0)