HTML Attributes

Attributes in HTML are provided additional information about HTML elements. HTML tags like heading tags <h1>, <h2> and paragraph tags <p> can have multiple attributes to define their characteristics.

Attributes name and value pair

  • All HTML elements can have multiple attributes.
  • Attributes provide an additional piece of information about elements.
  • Always specify an attribute in a start tag.
  • Specify the attribute in name="value" pair.

Name – Specify the name of the property you want to set. For example, the <p> element can have the attribute name font-size to change its size.

Value – Value specifies the value of the property you want to be set. For example value for the font-size property set to “16px”. Always enclosed value inside double-quotes.


<!DOCTYPE html>
<html lang="en">
<p style="color:red;">This is a red paragraph.</p>
<img src="" alt="Girl with a jacket">

The lang attribute tells about the language used on the webpage, and the "en" value is used for English. Style attribute used for inline styling of an element. HTML src attribute used in the img tag tells the location of the image file.

Leave a Reply

Your email address will not be published. Required fields are marked *