Attributes in HTML


  • Attributes are used to define properties of HTML document.
  • Attributes are case sensitive.
  • World Wide Web Consotorium(W3C) suggests using lowercase attributes while writing HTML documents.
  • Attribute consists of two parts:
    1. Name-It defines property that is to be set.
    2. Value-It defines value we want to set for that particular property.
    3. Method-name="value"

Title attributes

These attributes are used to provide certain idea about the content of particular HTML element.Varius search engines like Google use these attributes as reffernce for type of data contained by certain HTML documents.

Example:

<!DOCTYPE html>
<html>
<head>
<title>About Coding.</title>
</head>
<body>
<p alt="About CODEhunt">CODEhunt is designed to serve the purpose of making people aware of famous web development languages.</p>
</body>
</html>

Output:

CODEhunt is designed to serve the purpose of making people aware of famous web development languages.

Here About Coding will be displayed as the title of web page on top of your browser window and when you will point you cursor over <p> element you will see a toolpit showing About Coding.

alt Attribute,size attribute

alt element is used to display alternative text to be displayed when HTML is not displayed properly. width and height are known as size attributes.

Example:

<html>
<head>
<title>About Coding.</title>
</head>
<body>
<img src="logo.jpg" alt="logo" width="104" height="145">
</body>
</html>

Output:

logo

href attributes

HTML links can be displayed by <a> tag but to specify link address we use href attribute.

Example:

<!DCOTYPE html>
<html>
<head>
<title>
href attribute </title>
</head>
<body>
<a href="www.codehunt.com">This is link.</a>
</body>
</html>

Output:

lang attribute

lang attributes provides information about language content of HTML.This tag tells browsers and search engines about ype of language used in writting HTML documnets.

Example:

<!DOCTYPE html>
<html lang="en-US">
<html>
<title>
<head>
lang attribute </head>
</title>
This lang attribute is not displayed in output.