Tag selectors

Any HTML tag, for which formatting rules, such as colour, background, size, etc. are set, can be used as selector. Rules are set in this way:

Tag { property1: value; property2: value; ... }

In the beginning the tag name is indicated, the design of which will be redefined with upper-case or lower-case symbols, it doesn’t matter.  Inside of the braces the characteristic CSS is written, and after colon – it’s meaning.  The group of parameters is separated from each other with semicolumn and can be located in one line or several (example 5.1).

Example 5.1. Changing of the paragraph’s style.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  <title>Селекторы тегов</title>
  <style type="text/css">
   P { 
    text-align: justify; /* Выравнивание по ширине */
    color: green /* Зеленый цвет текста */
   }
  </style>
 </head> 
 <body>
 
   <p>More effective way of lion-hunting in the dessert is the method of gold cutest. Using it the dessert is divided into 2 unequal parts, the size of which submits to the rule of the gold cutest</p>
 
 </body>
</html>

In this example colour of the text and text alignment of the paragraph are changed. The style will be applied only to the text, which is the package <p>.

Note

You need to understand, that it is possible to add the style only to the tags, which are displayed in the package <BODY>.