Page 40 - 2403_Trackpad_V5.1_C6_Fb
P. 40
STYLING HTML5 DOCUMENTS WITH CASCADING STYLE SHEETS
CSS (Cascading Style Sheets) is a language used to describe how HTML documents should look and
be formatted. The latest version of CSS is CSS 3. Earlier, CSS 2 was used. CSS comprises style rules
that are interpreted by the web browser and then applied to the corresponding elements in the HTML
web page. CSS is the language that describes the look and formatting of a document written in HTML.
SYNTAX OF CASCADING STYLE SHEET
The Cascading Style Sheet has two parts: selector and declaration.
Selector Declaration
HI { Color : Blue; Font-Size : 12px; }
Property Value Property Value
The selector specifies the element to which we want to apply the formatting and the declaration
specifies the formatting to the selector.
The property of CSS is used to create a style.
Value is the valid value for the property.
A semicolon should be used at the end of the property-value pair if more than one property is used.
Some of the properties and their values of CSS are given below:
Property Value Description
Background-Color Name of the colour Specifies background colour.
Color Name of the colour Specifies the text colour used in the webpage.
The three ways to use CSS in HTML documents are described below:
INLINE CSS
An inline style is used to apply a unique style to a single element. Inline styles are added directly to
an HTML tag by using the STYLE attribute with the tag. Syntax to use the style attribute with a tag:
<TAGNAME STYLE = “PROPERTY:VALUE;”>
For Example:
<BODY STYLE=”BACKGROUND-COLOR:RED; COLOR:RED”>
TEXT IN RED COLOUR
</BODY>
INTERNAL CSS
Internal CSS allows us to define the style for a single HTML page. It is defined using the <STYLE> tag
in the head section of the HTML page.
38 Premium Edition-VI

