Element Attributes

Attributes contain extra information about the element that you don’t want to appear in the actual content (Placed in the opening tag).

Here, “class” is the attribute name and “text”  is the attribute value. The class attribute allows you to give the element a non-unique identifier that can be used to target it (and any other elements with the same class value) with style information and other things.

An attribute should always have the following:

  1. A space between it and the element name (or the previous attribute, if the element already has one or more attributes).
  2. The attribute name is followed by an equal sign.
  3. The attribute value is wrapped by opening and closing quotation marks.

Please note the “id” attribute here is a unique identifier while the class attribute for instance is a non-unique identifier

Scroll to Top