CSS id is the name(id or identity id ) of the block of code by which we called the CSS block of code. You can call a CSS block code via the CSS id. Without CSS id you can't call the CSS in HTML. Every block of code has a different CSS id name. CSS id name is not similar to another CSS id. We can create multiple CSS id. Every id name has different properties. CSS id is a unique identifier of the CSS block. If you don't want to use CSS id then you can use CSS class . The CSS class is similar to the CSS ID but there is a small difference in class and id.
A website can contain multiple CSS id. The developers create the CSS id according to website design. Multiples CSS id have different effects on DOM (HTML structure).
CSS id syntax
#id-name{
}
CSS id name is written with # sign . The id name may be anything. You can choose according to your need. If you are working on Header then you can take CSS id name as #header. if you are working on the body then you can take as #body etc.
Create a Simple CSS id
Creating an id according to your need . The following example will show you, how to create CSS id using
CSS attributes and Property
#header{
height:200px;
width:800px;
background-color:grey;
color:white ;
}
We have creates a simple header id and use some CSS attributes and Property.
Now call the CSS id in HTML to see the effect .
CSS id call in HTML
Calling CSS id is very simple you have to use div element and simple class .
CSS id in HTML
<!DOCTYPE html>
<html>
<head>
<title>CSS id </title>
</head>
Please note, this is a STATIC archive of website technosmarter.com from July 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
</body>
</html>
Run
In he above example, we have called the CSS by its id name.