CSS (cascading style sheet) An Introduction

CSS:

CSS or cascading style sheet is a style sheet language used to desribe the look and formatting of a document written in HTML and XML
CSS describe how element should describe on website

Basic syntax of CSS

selector like we have to apply CSS on paragraph than
p {font-size: 20px;}


There are three types of CSS

  1. Inline CSS

  2. Internal CSS

  3. External CSS


Inline CSS :-

Inline CSS practice of including css directly within the html document rather than a seprate sheet this is archieved by using style attribute within html tag like syntax "

p style = "color:red; background color:red;


Internal CSS :-

internal CSS refers to the practice of including CSS directly within a HTML document rather than a separate file its placed inside the style element syntax like:-
< style >
h1(
color: red;
)
< /style >


External CSS :-

external CSS refer that are stored in separate files and linked to HTML document CSS is a
stylesheet language to describe there presentation of a document written in HTML or XML
its making code more modular and easier to maintain


Here are the some basic step to use external CSS

  1. Create a CSS file

  2. Write CSS rules

  3. Link CSS to HTML


Selector in CSS:

  1. Universal Selector

  2. Element selector

  3. ID & Class selector

  4. Group selector

  5. Descendant selector

  1. Universal selector

    universal selector is denoted by an asterisk(*). it is a special selector that matches any element when used in a CSS file when used in CSS rule,
    the universal selector applies style to every element on a webpage

     structure like
                  *{ 
                 margin:0;
                padding:0;
            box-sizing:border-box;
                   }
    
  2. Element selector

    target html element based on their tag name .it is one of the most straight forward and commonly used selectors in CSS.
    to apply style to a HTML element use element selector followed by element's tag name

             p{
             style must be there;
              }
    
  3. ID selector

    way to select and style a specific HTML element based on its unique identifier .the id selector is denoted by the hash (#) followed by id value

     structure like
             #myElement{
                 color:blue;
                 font-size:16px;
                       }
    
  4. Class selector

    class selector used to select elements based on their class attributes . their classs attributes allow you to apply styles to multipe html element using a single class name.
    period(.) followed by class name itself

     syntax is like
                 .myclass{
                     color:red;
                     font-size:10px;
                        }
    
  5. Group selector

    not a standard term or selector refer to combination of selectors to target specific groups of elements in your HTML document

     structure like
                 h1,h2,h3,p{
                     color: blue;
                     background-color: red;
                          }