5) id Attribute:
- The
id
attribute is used to uniquely identify any element within an HTML page. - The
value
of id attribute must be unique within an HTML documents. - You cannot have more than one elements with the same id in an HTML documents.
Syntax:
<p id = "home"> This is a home page </p>
Code:
<!DOCTYPE html>
<html>
<head>
<title>id Attribute</title>
<style>
#home{
background-color: violet;
text-align: center;
padding: 40px;
font-weight: 200;
font-size: 20px;
}
</style>
</head>
<body>
<h1>id Attribute</h1>
<p> Use CSS to style an element with the defined id.</p>
<p id = "home"> This is a home page </p>
</body>
</html>
Output:
6) title Attribute:
The title
attribute is used to give a suggested title for an element. It provides some additional information about an element.
Syntax:
<p title="I'm a title inside html body section"> The title attribute is used to give a suggested title for an element. <br/>It provides some additional information about an element.</p>
Code:
<!DOCTYPE html>
<html>
<head>
<title>My Title</title>
</head>
<body>
<h1>My Title</h1>
<p>
<b>Mouse Hover on below paragraph to see the uses of title attribute inside body in an HTML documents.</b>
</p>
<p title="I'm a title inside html body section"> The title attribute is used to give a suggested title for an element. <br/>It provides some additional information about an element.</p>
</body>
</html>
Output:
My Title
Mouse Hover on below paragraph to see the uses of title attribute inside body in an HTML documents.
The title attribute is used to give a suggested title for an element.
It provides some additional information about an element.