Advertisement

Advertisement


HTML Attributes

An HTML attribute defines the characterstics of the HTML element, which also modifies the properties of it.

  • Attribute defines the characterstics of HTML elements.
  • Attributes are specified in the opening tag.
  • All HTML elements can have attributes.
  • Attributes provide additional information about an element.
  • Attributes are always specified in the start tag.
  • Attributes usually come in name/value pairs like: name="value".
  • Ex.- 'src' in <img> tag OR 'href' in <a> tag,etc..

HTML Lang Attribute

The 'lang' attribute is declared in the <HTML> tag. It allows you to indicate the main language used in html document.

Although it is not necessary to use but using it is a good practice.

List of all Language attribute used in HTML are here Click here


<!DOCTYPE html>
<HTML lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Lang Attribute </title>
</head>
<body>
<p> This page is using English Language. </p>
</body>
</html>

Output

HTML Lang Attribute

This page is using English Language.


HTML Title Attribute

The behaviour of this attribute will depend upon the element that carries it, although it is often displayed as a tooltip when cursor comes over the element or while the element is loading.


<!DOCTYPE html>
<HTML lang="en">
<head>
<meta charset="UTF-8">
<title> The Title Attribute </title>
</head>
<body>
<h3 title= "Hello HTML"> The Example of Title Attribute </h3>
</body>
</html>

Output

HTML Title Attribute Example

WHO was founded in 1948.

CodeRepublics.com


HTML Src Attribute

In Html, images are added with <img> tag. In <img> tag the src attribute is used to specify the filename and address of the image.


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Alt Attribute </title>
<body>
<img src="HTML-Image.png" alt="HTML5 Image" style="width:400px; height:250px;">
</body>
</html>


HTML alt Attribute

The alt attribute specifies an alternative text to be used, if somehow the browser is not able to diaplay an image. Also value of the attribute can be read by screen readers, which helps visually impaired person to "hear" informaiton about the image.

If a browser cannot find an image, it will display the value of the alt attribute :


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Alt Attribute </title>
<body>
<img src="HTML-Image.png" alt="HTML5 Image" style="width:400px; height:250px;">
</body>
</html>

Output

HTML Image Alt Attribute Example HTML5 Image

HTML style Attribute

The style attribute is used to specify the styling of an element,i.e. it defines the CSS styling of element like color, font, size etc.


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Inline Styles </title>
</head>
<body>
<h4 style="color:green"> This is Green Color </h4>
<h4 style="color:blue"> This is Blue Color </h4>
</body>
</html>

Output

Inline Style

This is Green Color

This is Blue Color










Become a Patron!

Note: If the updated content is not visible to you please refresh the cookies by pressing CTRL + Shift + R.