HTML Attributes

HTML Attributes

HTML Attributes
We have seen some HTML tags in the HTML language and their usage such as heading tag <h1>, <h2>, paragraph tag <p> and other types of tags. We have learned to use these HTML tags easily, but most HTML tags can contain attributes Attributes provide new look to HTML elements and add new properties to them.

  • All HTML elements have attributes
  • It serves to provide additional information about the element
  • It always specifies properties in the start tag
  • Usually this name / value comes in pairs

 name = "value"

The name is the property in which you want to set. At the end of the example, the heading <h> element has an attribute whose name is assumed to be aligned, which you can use to indicate the alignment of the heading on the page, it is linked to the name of the attribute.

Now let's talk about the attribute value.
The value is in which you want to set the value of the property and it is always put inside the quotations. At the end of the example - <h1 align = "left"> In this example, the name align ("left") and ("left") is the value of the attribute.

HTML Attributes

Href Attributes
<a> Tag is used to link the link to HTML. And the link address is specified in the href attribute, this is the very important tag that is used on a higher level:


<a href=""> this webstudy is a link </a>

The src attribute
The <img> tag is used to display images inside HTML pages.
The image file source is specified by the src name attribute:


<img src = "web_study.jpg">

Width and height attribute
In HTML the image has a set for size specifications, which specifies the width and height of the image, with the help of this, we can make the image smaller or larger depending on our page:

<img src = "web_study.jpg" width = "500" height = "600">

Specifies the size of the image in pixels: width = "500" means the image is 500 pixels wide.

Alt attribute
When the reason for which an image can not be displayed, it specifies an optional text to use the alt attribute.

<img src = "img_a_sweet_girl.jpg" alt = "The Sweet Girl image">

The alt feature is also useful if the image does not exist:

The style Attribute
Style attribute is used to specify style.
For element, such as color, font, size, etc.


<p style = "color: red"> a paragraph </ p>

Result −

a paragraph

Lang attribute
The language of the document is declared in the <html> tag.

Language is declared along with Lang Attribute.


   <! DOCTYPE html&gt
   <html lang = "en-US">


     </ Body>
    </ Html>

Title attribute
Here, a title attribute that is added to the element. Such as in paragraphs The value of the title attribute is displayed when you mouse over the paragraph:


<P title = "web_player">
This is a paragraph.
</ P>

Result −

This is a paragraph.