CSS selectors
Notes:
HTML - Introduction to CSS selectors :
Selector is a string used to select elements on the page and apply styles on them.
There are 3 most commonly used selectors, they are :
Tag selector or element selector
Id selector
class selector
tag selector selects tags based on their tag name.
id selector selects tags based on their id attribute value.
class selector selects tags based on their class attribute value.
id selector prefixed by hash(#).
class selector prefixed by period(.) or dot(.).
id attribute values should be unique in the page.
class attribute values can be same for more than one element.
Interview Questions:
1. Which html attribute is used to name an element uniquely?
a. class
b. name
c. unique
d. id
Answer: d
2. Which CSS selector is used to uniquely identify an html element and apply styles on it?
a. tag selector
b. class selector
c. id selector
d. pseudo selector
Answer: c