What is Attribute?

 What is Attribute?

Attribute is a modifier of HTML elements on web pages and apps. By means of an attribute, you can apply changes to literally every web design element within HTML syntax. Color of the text, font type and size, alignment of objects within a page - all these are variations of values that you can add to a web page. In programming, attributes are defined as project properties, in database management systems, attributes are used to describe components of databases.

HTML attributes commonly appear in the form of name-value pairs. In the following example: content to be modified by the tag "tag" stands for the HTML element type; "attribute" is the name of the attribute; "value" is the value that you set to the attribute.

Attribute types

There are 4 core attribute types that are commonly used on HTML pages. these are:

  • id
  • title
  • class
  • style

The id Attribute is used to identify uniquely any element within an HTML page. One of the reasons why you will need to use the id attribute is because this is a unique attribute, letting you identify one particular element and its content. Another reason is that by means of the id attribute you can differentiate two elements under the same name within one style sheet.

EXAMPLE

to explain what is HTML

to explain what is CSS

The title attribute provides a suggested title/name to the element. The title syntax is pretty much similar to the one of the id attribute. Depending on the element that carries an attribute, its behavior will vary.

For example, you can display a title that carries a tooltip when a cursor is placed over it:

The title Attribute Example

Titled Heading Tag Example

The class attribute is applied to associate elements with style sheets. Simply put, it specifies the class of an element (e.g. class="className1 className2 className3").

The style attribute lets you specify CSS rules within a specific element. With the help of this element, you can manage the color, font type and size of your text (

Some text...

).

Related terms: CSS, HTML, page title, font.

References and further reading: