ad

Friday, January 2, 2026

Learn CSS Selectors Step by Step

Learn CSS Selectors Step by Step

web designing theory

CSS Selectors

  • css selectors  patterns use css identify and select HTML element on webpage that styles can be applied to them.
  •  CSS selector type  refers to different way can select HTML  element.
  • CSS selector has specific target elements.

Learn CSS Selectors Step by Step 

Type of CSS Selector (element)

  1.  Universal selector (*)
  2. Element Selector
  3. Class Selector(.)
  4. ID Selector(#)
  5. Grouping Selector
  6. Attribute Selector
  7. Pseudo-class Selector
  8. Combinator  Selectors
            1)  Descendant Selectors
            2)  Child Selector(>)
            3)   Adjacent  Sibling Selector(+)
            4)  General Sibling Selector 
      

Learn CSS Selectors Step by Step

Syntax 

 selector
property:   value;
property:   value;

}

Learn CSS Selectors Step by Step

Example 

<!DOCTYPE html>
<html>
<head>
<title> CSS Selector </title>

    <style>
     p{  text-align:center;
         color:rgb(19, 47, 253);
         
             }

    </style>
</head>
<body>
 <p>Hello every one</p>
  <p>learn to programming language</p>
   <p id="pro">HTML,CSS,PHP</p>
 <p>https://webdesigningtheory.blogspot.com/</p>
 
</body>
</html>

Learn CSS Selectors Step by Step

Explain Program

Step  1] 

<!DOCTYPE html>

  • This declare the document type.
  • browser that the document is written in html

Step 2 ]

<html>

  • html is the root element of the html page.
  •  Every thing inside it is part of the webpage.

Step 3]

<head>
        <title> CSS selector </title>


  •   <head>  section 
  •   head section contains metadata about page. not visible on the page itself.
  •  <title> tag  title section set the title of the page shows the browser tab.
Step 4]

<body>

  • Contains all visible of the webpage.
  • Everything inside <body> tag visible content of the webpage.
  • User will display/see their browser.

Step 5]

 
<style>
     p{  text-align:center;
         color:rgb(19, 47, 253);
         
             }   

    </style>

  •  <style> use to css directly (internal CSS) in the HTML  file.
  •  <style> inside anything is css code that applies to the HTML page.

  • target all paragrapha  <P> elements on the page.
  •  contains  CSS  {. . .} rules that apply to elements.


 text-align:center;

text-align:center this rule centers the horizontally inside each <P>

 color:rgb(19, 47, 253);

color sets text color is blue

Step 6]

<body>
 <p>Hello every one</p>
  <p>learn to programming language</p>
   <p id="pro">HTML,CSS,PHP</p>
 <p>https://webdesigningtheory.blogspot.com/</p>
 

  • <P>  stands for paragraph 
  • create  paragraph on the web page with text.
  • hello  every one
  • default paragraphs are displayed on new line.  

   <p id="pro">HTML,CSS,PHP</p>

 paragraph a unique identifier.

Step 7]

closing the Tag

</body>
</html>

Learn CSS Selectors Step by Step

Output

web designing theory
















RelatRelated Post :-

How to use the kbd tag in html

How to use the footer tag in HTML

 How to use html search input type