23 of 133 menu

The id attribute

The id attribute specifies a unique identifier for the tag so that it can be referenced via CSS.

The names id must be typed in English letters, numbers, without spaces. The value of the id attribute must not begin with a number (this is already possible in HTML5, but will not work in older browsers).

Example

Let's now set the paragraph that has an attribute with id set to elem to have red text color:

<p id="elem">text</p> <p>text</p> #elem { color: red; }

:

See also

  • attribute class,
    which assigns classes to elements
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline