Home HTML CSS JAVASCRIPT BOOTSTRAP Python Docker ML tutorial About us Privacy policy

Attributes In HTML

Introduction


Attributes In HTML

  • Every HTML element can contain attributes.
  • Attributes are in form of name, value.
  • Every attribute must have it's name and it's value as well.
  • Attributes are always write inside the tages.

The Align Attribute:

The align attribute defines the align of the text, possible values of the align attribute are left,right and center.

<h3 style="color: blue; font-size: 50px;">
Codes Family.</h3>
<div align="right">
  right text align</div>
<div align="left">
  left text align</div>
<div align="center">
  center text align</div>
  
  

The Style Attribute

The Style Attribute is used to add styling such as font, color,background-cloor etc.

Example:
<h3 style="color: blue; font-size: 50px;"> Codes Family. </h3>
    

The Src Attribute

The src attribute is used to add images on the HTML documents.

syntax

<img src="Path(url)" />
Example:
 <img src="code.jpg" />

The alt Attribute

The alt attribute is used to display text when image is not ready to show.

Example:
<img alt="Codes Family" src="code.jpg" />

The href Attribute

The href attribute define inside anchor tag syntax tag. we define hyper link inside the href attribute.

Example:
 <a href="https://www.codesfamily.com/"></a>

The Height and width Attributes

The height and width attributes are use to specify the height and width of the images.

Example:
<img height="400" src="code.jpg" width="400" />

The title Attribute

The title attribute is added in p element. The value of title will be display when your mouse over the pragraph.

Example:
<div title="code is my life">Codes Family</div>

Id Attribute

The id attribute is used to uniquely identify any HTML element within HTML page. Two elements can not contain same id attribute.

Example:
<div id="p1">
My paragraph</div>
<h1 id="heading">
My heading</h1>

The Class Attribute

In HTML the class attribute is used to styling operations on the HTML elements. Two elements can contain same class attribute.

Example:
<div class="code">
  My Paragraph</div>
<h1 class="code">
 My Heading</h1>
The lang attribute is used to specify the language used in HTML document, and we can write lang attribute inside HTML tag only. Example:
<html lang="en">
<head>
  <title>The lang attribute</title>
</head>
<body>
  <h1>
This is using English language.</h1>
</body>
</html>

The Dir Attribute

The dir attribute is used to display the direction of text to be display in the browser.We can write dir attribute inside HTML tag.

Example:
<html dir="rtl">
<head>
  <title>The dir attribute</title>
</head>
<body>
  <h1>
Text is display from left to right</h1>
</body>
</html>

Single Quotes and Double Quotes

Double quotes are very commonlly use in HTML but we can also use single quotes as well without any problem.

Example:
<html>
<head>
  <title></title>
</head>
<body>
  <div align="right">
    Right align</div>
  <div align="center">
    Center align</div>
</body>
</html>