What is the difference between class selector and ID selector?

0

1. Class selector can be given to an overall block. This is sometimes termed as block element as well, whereas ID selector identifies a unique name and a style for a specific element.
2. ID selector declares the style for only one particular element which can be differentiated from other element, whereas Class selector is being given for the whole complete block.
Example of ID selector is being written like this:
#idname {color: red; background: black;}
This can be used in HTML as
this element only will be affected by the use of this ID element

Css
asked Apr 14, 2023 at 18:52
Sign in to add a comment

0 Answers

0
📝 No answers yet!

Be the first to answer this interview question.

Your Answer

Sign in to post your answer and help the community.