CSS Attribute Selectors

CSS Attribute Selectors

CSS attribute selectors allow you to select HTML elements based on their attribute values. They provide a way to target specific elements that have certain attributes or attribute values. There are several types of attribute selectors in CSS:

  1. Attribute presence selector: Selects elements that have a specified attribute, regardless of its value. The syntax is [attribute]. For example, [required] will select all elements that have the required attribute.
  2. Attribute value selector: Selects elements that have a specific attribute value. The syntax is [attribute=value]. For example, [type="text"] will select all elements that have the attribute type with a value of "text".
  3. Attribute substring value selector: Selects elements that have an attribute value containing a specific substring. The syntax is [attribute*=value]. For example, [href*="example"] will select all elements that have an attribute href containing the substring "example".
  4. Attribute prefix value selector: Selects elements that have an attribute value starting with a specific prefix. The syntax is [attribute^=value]. For example, [class^="btn"] will select all elements that have a class attribute starting with "btn".
  5. Attribute suffix value selector: Selects elements that have an attribute value ending with a specific suffix. The syntax is [attribute$=value]. For example, [src$=".png"] will select all elements that have a src attribute ending with ".png".
  6. Attribute exact value selector: Selects elements that have an attribute with an exact value. The syntax is [attribute=value]. For example, [target="_blank"] will select all elements that have a target attribute with a value of "_blank".
  7. Attribute space-separated value selector: Selects elements that have an attribute with a specific value in a space-separated list. The syntax is [attribute~=value]. For example, [class~="active"] will select all elements that have a class attribute with "active" as one of the space-separated values.
  8. Attribute value starts with selector: Selects elements that have an attribute with a value that starts with a specific value, followed by a hyphen. The syntax is [attribute|=value]. For example, [lang|="en"] will select all elements that have a lang attribute with a value that starts with "en" followed by a hyphen.

These are some of the commonly used CSS attribute selectors. They provide powerful ways to target elements based on their attributes and attribute values, giving you more control over styling and behavior.

Leave a Reply

Your email address will not be published. Required fields are marked *

GLOTRU Footer
Popular Features
Popular Services/

Website Development & Design

App Development & Design

Graphic Design

Digital Marketing

SEO (Search Engine Optimization)

SMM (Social Media Marketing)

Cyber Security

Company

GLOTRU Founder & CEO : __Azam

Registared : Trade,MSME,etc

Board of Director

Team

About Us

Contact Us

Privacy Policy

Return & Refund Policy

Abuse Policy

Copyright Policy

Cookie Policy

Terms & Conditions

Universal Terms of Service

Disclaimer

Legal

Sponsorships

Investor

Press Releases

Our Investments

Brands

Newsroom

Business

...

_

Digital Millennium Copyright Act
DMCA.com Protection Status

_

Content similarity detection
Protected by Copyscape

_

***ANTI-PIRACY WARNING***

...................................................................................

Follow Us :

...................................................................................

SECURE SERVER : [Legal] [Privacy Policy] [Universal Terms of Service] [Do not sell my personal information]

SITE HOSTED : GLOTRU SECURE SERVER Asian Data Centre [You can host your site][Click Here]

SSL : Server Type : [Cloudflare] Certificate Issued By : [Let's Encrypt] Signature Algorithm : [ECDSA with SHA-384]

SITE BUILD SOFTWARE : Content Management System (CMS) Softwere

_

_

_