Do you want to be a good Web Developer?

Enter Your Email To Get Our Exclusive Tutorials
And Offer Right In Your Email

HTML Attributes

HTML Attributes


Attributes is used to provide more information of an element all attributes have name and its value and attributes must be placed inside the opening tag of the element.


This is how any attributes is define attributename="value".


Some of the main attributes are as follows which is used in almost every element:-

  • id:It define the unique identity of an element in the complete webpage.

  • Example of "id"

    <p id="para 1">This is the example of id</p>

    Code Explanation

  • In this example paragraph having id attributes and its value is para 1.



  • class:It is used to associate an element with a style sheet, and specifies the class of element.You will learn more in HTML Style chapter and in CSS Tutorials.

  • Example of "class"

    <p class="paragraphs">This is the example of class</p>

    Code Explanation

  • In this example paragraph having class attributes and its value is paragraphs.
  • It is possible more than one element having the same class value.



  • name:It also used to identify the element.You will learn more in PHP tutorials.

  • Example of "name"

    <p name="demo">This is the example of name</p>

    Code Explanation

  • In this example paragraph having name attributes and its value is demo.
  • It is possible more than one element having the same name value.



  • style:It is used to give the style(CSS) of that element in inline way.You will learn more in HTML Style Chapter and in CSS Tutorials.

  • Example of "style"

    <p style="color:blue;">This is the example of style.</p>

    Result of the above example

    This is the example of style.


    Code Explanation

  • In this example paragraph having style attributes and it has CSS element color and its value is blue.You will learn more in HTML Style Chapter and in CSS Tutorials.
  • The color of the text inside the paragraph is blue because we use the color element and its value is blue.



  • lang:It is used to define the main language of used in the document.It always define in html opening tag.

  • Example of "lang"

    <html lang="en">
    <body>
    <p>This is the example of lang attribute.</p>
    </body>
    </html>

    Code Explanation

  • In this example html having lang attributes and the value is en. en represents that the document is using English language.



  • title:It provides extra information of an element by displaying title value in tooltip when you hover on that element.

  • Example of "title"

    <p title="Example of title">This is the example of title.</p>

    Result of the above example

    This is the example of title.


    Code Explanation

  • In this example we use title attribute the value is "Example of title" whenever the mouse is over that element a tooltip is displayed and the title value is shown.

PreviousNext

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email