CSS - Attribute Selector


CSS - Attribute Selector

  • In CSS, [attribute] selector is used to select elements with a specified attribute.
  • An attribute selector will match elements on the basis of either the presence of an attribute, or the exact or partial match of an attribute value. 
  • Attribute selectors select an element using the presence of a given attribute or attribute value.
  • Given below are the following rules applied to attribute selectors:
  • [attribute] Selector
    • [attribute="value"] Selector
    • [attribute~="value"] Selector
    • [attribute|="value"] Selector
    • [attribute^="value"] Selector
    • [attribute$="value"] Selector
    • [attribute*="value"] Selector