Others




What is CSS?


CSS stands for Cascading Style Sheets.CSS is the language used to style HTML document. We can change font styles, colours, positions, spacing between paragraphs, element size and etc.There are three ways of adding a style sheet:

  • Inline Style
  • Internal Style
  • External Style

Inline Style

We can apply a style to one element at a time.

Example
<html>
  <head>
    <title>Inline Style</title>
  </head>
  <body>
	<h1 style='color:green;'>Hello World</h1>
	<p style='font-size:18px; color:red;'>Sample Paragraph</p>
  </body>
</html>
Try it Yourself

Internal Style

We can add a unique style to a single HTML document.

Example
<html>
  <head>
    <title>Internal Style</title>
  <style>
    body{
      background-color:red;
    }
    p{
      font-size:18px; 
      color:red;
    }
  </style>
  </head>
  <body>
    <h1>Hello World</h1>
    <p>This is a sample paragraph.</p>
  </body>
</html>
Try it Yourself

External Style

We can apply styles to a whole website using external stylesheet.

style.css
h1{
  color:#ccc;
}
p{
  color:green;
  font-size:16px;
}
index.html
<html>
  <head>
    <title>Internal Style</title>
	<link rel='stylesheet' type='text/css' href='style.css' >
  </head>
  <body>
    <p>This is a sample paragraph.</p>
  </body>
</html>