How to Apply CSS

How to apply CSS to HTML

There are 3 ways to apply CSS to HTML

  1. As an Inline CSS
  2. As an Internal CSS 
  3. As an External CSS Document
  • Inline CSS
    Inline CSS Style is included to the HTML tags using style attribute. Inline styles apply to the defined segment only. Each propery seperated by ";".
    Ex:
    <a style = "color : Blue">This is a Inline styled Text</p>

  • Internal CSS
    Internal CSS styles can be used to the whole HTML Document and defines inside the header segment using style tag. Each propery seperated by ";".
    Ex:
    <html>
       <head>
          <style = "text/CSS">
             a{
                color : blue
             }
            body{
               color : red;
               background : orange
            }
       </style>
    </head>
    This Stlyes apply for the whole body of the HTML document & all links

  • External CSS
    In this method, using a seperate CSS file to format the HTML Document. It saved with extention of CSS ank link to the HTML document.
    Ex:
    myStlye.css
    P{
       color : blue
    }
    body{
       background-image : url("images/backgroung.jpg")
    }

    MyFile.html
    <html>
       <head>
          <link rel = "stylesheet" type = "text/css" href = "myStyle.css" />
       </head>
       <body>
          .....
       </body>
    </html>

No comments:

Post a Comment