ID Selector

  • 0


2)  #id


 The #id selector styles the element with the specified id.

The #id selector is supported in  Internet Explorer Firefox Opera Google Chrome Safari 



 Syntax

#id
{
 declarations;
}




 


<html>
<head>


<style>
#firstname
{
background-color:yellow;
}

</style>


</head>
<body>

<h1>Welcome to My Homepage</h1>

<div>
<p id="firstname">My name is Donald.</p>
<p id="hometown">I live in Duckburg.</p>
</div>

<p>My best friend is Mickey.</p>

</body>
</html>



 
 



<html>
<head>
<style>
span#identified
{
  background-color: green;
   color: yellow;
}

</style>
</head>
<body>

<h1>Welcome to My Homepage</h1>

<span id="identified">ID selectors match an element based on the contents of that element's ID attribute, which must match exactly the value given in the selector.
</span>
<br> <br> <br>
<span>Here's another.</span>

</body>
</html> 






No comments:

Post a Comment