Using Class and ID


#1

Was just confused.
What’s the difference in using class and id for css.
link: https://www.codecademy.com/courses/learn-css-selectors-visual-rules/lessons/css-setup-selectors/exercises/id-name?action=lesson_resume&course_redirect=learn-css


#2

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


#3

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>

#4

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