WT Chap 2 CSS
WT Chap 2 CSS
2. Document 3. External
Level Level
Inline Level Style sheet
• This is the lowest level.
• Inline style sheet apply to the single
element and that’s why they are not
preferred more
• Inline style sheets are declared
within individual tags and affect
those tags only
• Inline sheets are declared within
the style attribute.
Inline Level Style sheet
• The general form for inline level is
given below
• style=“property_1:value_1;
property_2:value_2;
……..property_n:value_n;”
Sample program for Inline style sheet
Example.html Example.css
External Level Style Sheet
• External style sheets are called
using the <link> tag which is placed
inside the <head> tag of the HTML
document.
• The <link> tag takes three
attributes
• rel: rel stands for relation.
This attribute defines the relation
between a linked resource and the
current document.
Example: rel=“stylesheet”
External Level Style Sheet
• type- this attribute defines what type
of document it is.
Example: value=“text/css”
• href- it denotes the name and the
location of the document where where
CSS code is been writtenExample:
href=“c\BCA\example.html”
Example
Output
CSS Syntax
Decleration
Selector
h1{color:red; background:green}
Seperator
Property Value
Colon
Parts of style rule
The style rule is made up of three
parts
1. Selector: It indicates the name of
the tag at which the style will be
applied.
2. Property: the attributes of html are
converted to CSS properties.
3. Value: Values are assigned to
properties.
Types of Selectors
SELECTORS
Universal Selector
Example:
h1{font-size;20pt}
h2,h3{font-size:12pt}
Simple Selector
Simple Selector
Class Selector
This selector allows different
occurrences of the same tag to use
different style specification.
Example
<head><style>
p.cs1{color:red;font-size:12pt}
</style></head>
<body>
<p class=“cs1”>This used class selector
</body>
Generic Selector
Generic selector applies to more than
one element/tag.
This is implemented without using the
tag name.
Example:
.mine{color:red;font-size:30pt;}
Generic Selector
Generic Selector
Id Selector
Id selector allows the application of a
style to one specific element.
Example:
#select1{color:green;font-
size:10pt;}
#select2{color:red;font-size:20pt;}
Id Selector
Id Selector
Universal Selector
Universal selector applied the style to
the all the tags present in the html
document.
Universal selector is represented with
* symbol
Example:
*{font-size:30pt}
Universal Selector
Universal Selector