Attribute Selectors

Attribute Selectors

You can also apply styles to HTML elements with particular attributes. The style rule below will match all input elements that has a type attribute with a value of text:

input[type=“text”]{
color: #000000;
}

The advantage to this method is that the <input type=“submit” /> element is unaffected, and the color is applied only to the desired text fields.

There are following rules applied to attribute selector.
  • p[lang] - Selects all paragraph elements with a lang attribute.
  • p[lang=“fr”] - Selects all paragraph elements whose lang attribute has a value of exactly “fr”.
  • p[lang =“fr”] - Selects all paragraph elements whose lang attribute contains the word “fr”.
  • p[lang=“en”] - Selects all paragraph elements whose lang attribute contains values that are exactly “en”, or begin with “en-”.
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad