0
Please give me simple example of different type of selectors in CSS
I need examples of type,universal and descendant selector
3 Answers
+ 2
Universal Selector:
-> Selects all elements in HTML document.
-> It is implemented using * symbol.
Example:
* {
color: green;
}
# Using this, the text color of whole document will be green unless overridden by other style rules.
Type Selector:
-> Selects specific elements of HTML document.
Example:
div{
color: blue;
text-align: center;
}
#Usi this, the text color of all div tags will be blue and text align will be center unless overridden by other style rules.
Class / ID Selector:
-> Selects the special class/ id of HTML document.
-> Class Selector is implemented using .class (dot)(className).
-> ID Selector is implemented using #id symbol.
Example:
.para{
text-align: center;
}
#main{
background-color: gray;
}
# Using this, the text alignment of all elements with class para will be center. and the element with id main will have gray bg.
Descendant Selector:
-> Selects the elements which are the descendant of other elements
Example:
<div>
<p id="main>
<b>Hello</b>
</p>
</div>
div #main b{
color: red;
}
+ 1
//You missed this course
https://www.sololearn.com/learn/CSS/1080/?ref=app
0
universal *
direct child >