What are the components of a CSS Style?

Cascading Style Sheets (CSS) are primarily used to define the style, formatting and layout of a web page. CSS is primarily made up of different styles rules which indicate to the browser how the page should be displayed. Each style rule is made up of three different parts. In order they must be a selector, property, and a value.

  • Selector − an HTML tag to which the required style will be applied. This could be any tag such as <h1> or <table> etc.
  • Property − a type of attribute of an HTML tag. Basically, all HTML attributes are converted into CSS properties. They can be color, size, border, etc.
  • Value − assigned to properties. A color property can have a value, such as a specific color, size, border, etc. For example: red or #F1F1F1.

An example of a CSS Style would be:

<html>

  <head>

    <meta charset="utf-8">

    <style>

    #xyz { color: red; }

    </style>

  </head>

  <body>

    <p id="xyz" style="color: blue;"> To demonstrate specificity </p>

  </body>

</html>

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.