Lesson 1.7. ID attribute in HTML tags


HTML tags can contain attributes that are tag related information or properties. The general attribute syntax is:

<div attribute_name = "Property1 Property2 "></div>

Each tag has its own attributes, for example the tag <a> is generaly combined with the attribute href =" ... " which creates a link to another page.

You'll learn later that it is possible to create custom attributes for your own needs.

The ID attribute

The most used attribute is id which identifies a tag in particular. The following example shows the syntax for associating an identifier to a tag <h1>:

<h1 id="ID_name">My title</h1>

However, the following constraints should be considered:

See also

Last update : 03/10/2022