0

Please give me simple example of different type of selectors in CSS

I need examples of type,universal and descendant selector

9th Feb 2020, 2:46 AM
Ivan A. Ramos
Ivan A. Ramos - avatar
3 Respostas
+ 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; }
9th Feb 2020, 4:43 AM
March Zucherbug
March Zucherbug - avatar
9th Feb 2020, 3:54 AM
Sudarshan Rai
Sudarshan Rai - avatar
0
universal * direct child >
9th Feb 2020, 4:11 AM
Gordon
Gordon - avatar