Using Class and ID


Was just confused.
What’s the difference in using class and id for css.


Id is used for javascript and it can be used in both example. if you given id of an paragraph to id=“p” then you can use it on script and style but if you use class then you can only use it on paragraph


you can use the same “class” on two or more elements on your HTML tags, while “id” should be used to identify a specific element. Example:

<p class="red-text-p" id="item-0">item-0 -- sample text</p>
<p class="red-text-p" id="item-1">item-1 -- sample text</p>
<p class="red-text-p" id="item-2">item-2 -- sample text</p>


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.