1 - Tag selector and general syntax of a CSS code 

Before talking about the properties of a selector, let's take a simple example:

Example

For example to make the title tag H1 in red color, we use the code:

h1 {color: # FF0000; }

In this example:

  • h1 is called the tag selector (here it selects the title tag h1),
  • The command "color" here designate the selector property which is red in this case) from this example, we can deduce the general syntax of a CSS code:
Tag selector { property: values; }

2 - Example of CSS tag selectors

Example

For example, if you want the title tags to be in red with the size 22px, and the subtitle tags are in blue with the size 18px, you can  use the CSS code:

h1 {color: red;
  }
h2 {color: blue;
  }

Here is the complete code of the web page:

<Html>
<Head>
<Style>
h1 {color: red;
  }
h2
{Color: blue;
}
</Style>
<title> Tag selector </title>
</Head>
<Body>
<h1> Here's the title in red color ! </h1>
<h2> Here is the subtitle in blue color ! </h2>
</Body>
</Html>

 And here is the preview of the page:

Leave a Reply