Page 167 - CA_165_V2.0_Flipbook
P. 167
color: red;
}
Here, P is a selector and text-align is a CSS property.
Universal Selector (*)
Browsers apply default styles to HTML elements (such as margins, padding, and borders), which may
cause inconsistencies across different browsers in the appearance of the website. In another situation, if
you want to apply the same style to all elements on the page, the universal selector is an efficient way to
ensure consistency across the entire web page.
The universal selector is represented by an asterisk (*) and is used to apply styles to all elements on a
web page. It is one of the most basic and powerful selectors in CSS, allowing developers to define global
styles that affect every element.
Syntax:
*
{
property1: value1;
property2: value2;
}
Example:
* {
border: 1px solid black;
}
LINK STYLE SHEET
There are three ways of inserting or linking a style sheet:
External Style Sheet
Internal Style Sheet
Inline Style
External Style Sheet
By using 'External Style Sheet', look of an entire website can be changed by updating just one CSS file. To
do so, a web page must include a reference to the external style sheet file within a <LINK> tag inside the
<HEAD> tag. Syntax to use <LINK> tag in the web page:
<HEAD>
<LINK REL="stylesheet" TYPE="text/css" HREF="name of style sheet">
</HEAD>
Let us create a web page using external stylesheet. Perform the following steps to do so:
Step 1: Type the following code and save the file with .css extension.
BODY
{
BACKGROUND-COLOR:LIGHTBLUE;
Cascading Style Sheets 165

