Skip to main content

CSS - Cascading Style Sheet

CSS- Cascading Style Sheet


CSS is a set of rules (or formatting properties) that applies to a specific element in the web-page.
It is mainly used for formatting or designing the web-page contents.



CSS can be included in three different ways :-


  • Inline 
  • Embedded under HEAD tag
  • External Style-sheet

example:

1.INLINE

<html>
<head>
</head>
<body>
          <div class="abc">
             <p style="color:red;">Hello World</p>
          </div>
</body>
</html>

output:





2. Embedded under HEAD tag

<html>
<head>
         <style> 
             .abc
             {
                color:green;
             }
        </style>
</head>
<body>
          <div class="abc">
             Hello World
          </div>
</body>
</html>

output:




3. Stylesheet
<html>
<head>
          <link rel="stylesheet" href="stylesheet.css">
</head>
<body>
          <div class="abc">
             Hello World
          </div>
</body>
</html>

      External File:
      stylesheet.css
               .abc
               {
                  color:blue;
                  font-size:25px; 
               }

output:

Comments

Popular posts from this blog

HTML - Hyper Text Markup Language

HTML It is a markup language means it can distinguish between its elements and content. It instructs the browser how to display web-page content. HTML Tags these are the keywords in HTML which defines how browser will format and display the programmer's content on the web-page. It is of two types :- 1.One which requires closing tag     ex: <p> content </p>           <body> content <body> 2.One which doesn't requires a closing tag     ex: <img>           <meta>,etc HTML elements  it is the combination of                                <opening tag> content </closing tag> It is of two types :- 1.Inline    ex: <img src="abc/xyz.jpg"> 2.Block    ex: <p>hello there</p>

DOCTYPE html

<! DOCTYPE html> It is a declaration that instructs browser about what version of HTML is used in creating the web-page. Though it is not mandatory to write it in the html document but it is a good practice to include it. suppose we have not specified html version then the browser will itself assume a version, now it may happen that we have created a web-page using html-5 and someone is accessing it using an older browser which works on html-4 then some of our tags will not be rendered leading to some errors.