HTML Attributes

HTML Attributes

Attributes provide additional information about the contents of an element. They appear on the opening tag of the element and are made up of two parts: a name and a value, separated by an equals sign.

HTML attributes examples

<a href="https://www.w3tutorials.org">This is Link</a>

Here “href” is attribute name and “https://www.w3tutorials.org” is a attribute value.

Properties of HTML attributes

  • The attribute name indicates what kind of property adds to the element’s content.
  • Write HTML attributes name always in lowercase, it is good practice.
  • The value of HTML attributes should be placed in double-quotes.
  • Most attribute values are either pre-defied or follow a stipulated format.
  • HTML 5 allows you to use uppercase attribute names and omit the quote marks.

id Attribute

You want to set a unique identification to HTML tag then use this attribute in any HTML tag. you can call an element by using this method. The id Attribute can specify different properties like text color, font size, width, height, etc.

<p id="para1">This is a first paragaraph in HTML web page</p>
<p id="para2">This is a second paragaraph in HTML page.</p>

lang Attribute

The lang attribute defines web page language. below example will explain about lang attribute. Here an attribute called lang is used to indicate the language. The vale of this attribute on this page specified it is in US English.

<p lang="en-us">This paragraph in English</p>

target Attribute

The target attribute specifies where to open the link. By setting it to _blank, you tell the browser to open it in a new tab or window (per user preference).

<a href="example.com" target="_blank">Text Here</a>

Style Attribute

The Style attribute will style specified content for design purpose. These elements help people who use screen readers and also allow you to style these sections in a different manner.

<p style="color:red;">This is pargaraph in red colour.</p>

Browse a complete list of attributes in HTML Attribute Chapter.

You may also like...

Leave a Reply

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