Types of Selectors
Types of Selectors
1.ID SELECTOR
2. CLASS SELECTOR
1. <! DOCTYPE HTML> <HTML><head><style>. intro {text-align: center; color: blue} </style></head>
<body> <h1 class="intro">This heading is blue and center-aligned. </h1> <p class="intro">This
paragraph is blue and center-aligned. </p> </body></html>
1. <! DOCTYPE HTML> <HTML><head><style> p. intro {text-align: center; color: blue} </style></head>
<body> <h1 class="intro">This heading is not affected</h1> <p class="intro">This paragraph is blue
and center-aligned. </p> </body></html>
2. <! DOCTYPE HTML> <HTML><head><style> H1. intro {text-align: center; color: blue}
</style></head><body> <h1 class="intro">This heading is not affected</h1> <p class="intro">This
paragraph is blue and center-aligned. </p> </body></html>
3. UNIVERSAL SELECTOR
1. <! DOCTYPE html> <html><head><style> * {color: green; font-size: 20px;} </style></head><body> This
css style will be applied on Entire page. It does not check tag or plain text<br> <h2>This css is applied
to heading</h2> <p id="para1">it is applied to first paragraph</p> <p>Also to second paragraph!
</p></body></html>
4.GROUP SELECTOR
2. <! DOCTYPE html> <html><head><style> h1, h2, h3, h4, h5, h6, p {text-align: center; color: blue}
</style></head><body> <h1>Hello Heading 1</h1><br> <h2>HelloHeading2(In smaller font) </h2><br>
<h3>HelloHeading3(In smaller font) </h3><br> <h4>HelloHeading4(In smaller font) </h4><br>
<h5>HelloHeading5(In smaller font) </h5><br> <h6>HelloHeading6(In smallest font) </h6><br> <p>This
is a paragraph. </p> </body></html>
-END-