0
What is id and class in html
3 Respostas
+ 1
ID and class are both CSS Style selectors. In your CSS, when you format a style you initialize the name of that style. To use ID, initialize your style with # before the name. To use class, initialize your style with . before the name. Use either of them in your html code by calling "id=" or "class=". The both do the same thing. It is upto you to choose what you would want to use.
+ 1
They're also selectors for javascript
+ 1
.class
#id
Don't forget they override if they're all on the same tag:
the last class override the previous class
id override class
style override id
and using !important override them all
<style>
body {
background-color: black;
font-family: Monospace;
color: red;
}
#white-text {
color: white;
}
.blue-text {
color: blue !important;
}
.green-text {
color: green;
}
</style>
<h1 class="blue-text green-text" id="white-text" style="color: orange">Hi all!</h1>