HTML Id Attribute
The id attribute specifies a unique id for an HTML
element. This HTML id value can be used with CSS and Javascript to perform
certain task.
In css, if you want to select an element with a
specific id, write a “#” character.
<!DOCTYPE
html>
<html>
<head>
<style>
#myid
{
background-color: blue;
color: black;
padding: 40px;
text-align: center;
}
</style>
</head>
<body>
<h2>
Id Attribute</h2>
<p>Use
CSS to style an element with the id "myId":</p>
<h1
id="myid">My Id</h1>
</body>
</html>
|
Result:
Id Attribute
Use CSS to style an element with the id "myId":
My Id
|
EmoticonEmoticon