Stylesheet History
As early as 1993, people have been interested in adding more layout control to HTML.
Because of their theoretical benefits, style sheets have been the favorite solution of the
standard bodies. However it wasn’t until 1995 when bert bos of the W3C wrote chapter to
work on the introduction of a style sheet standard for the web.
Style sheet Basics
What does a style sheet do?Here is an example.consider the following:
Here is a simple text
To write this short sentence in HTML, you have to use many commands, such as
CENTER, FONT COLOR, FONT SIZE etc. Suppose you need to write this sentence 10
times, won’t it be easier to specify what you want only one time and simply write one
command instead of six. This is possible with style sheets
A style sheet is definition of how content should be rendered on the page. The purpose of
a style sheet is to create a presentation for a particular element or set of elements. Binding
an element to a style sheet specification is very simple. It consists of an element followed
by its associated style information within curly braces
Using ID
<html>
<head>
<style type=”text/css”>
# important
{
Background-color: yellow
}
</style>
</head>
<Body>
<p>this is the first paragraph</p>
<p id=”important”>example</p>
<p>this is the third paragraph</p>
</body>
</html>
Text Properties:
1) Letter-spacing-denotes the space between letters.the default value A variety of
measurements like inches(in),centimeters(cm),millimeter(mm),points(pt) etc can
be used
2) Word-spacing-denotes the space between words.Mesurements can be used similar
to letter spacing.
3) Vertical align-denotes the vertical positioning of the text and images,with respect
to the baseline.The possible values include baseline,sub,super,top,text-top,middle
paercentage values etc.
4) Text-align-specifies the alignment of the text.the possible values are center,justify
etc.text-align:center
5) Text-indent:denotes margins this property sets the indentation for text in first line
of a block level element.ex:text-indent:2.5em
6) Text-transform:denotes the transformation of the text.The possible values are
capitalize,uppercase,lowercase etc.
7) Text-decorate-denotes the text’s decoration.The standard values for this property
include blink,line-through,overline,underline etc
Absolute versus relative positioning
There are four different position types.The first is static,which is the current method that
HTML uses.The next type is absolute.this allows you offset elements based on the
browser borders.Another positioning type is relative.this lets you offset elements based
on the above element.The final type is fixed,which is similar to absolute,except the
element doesn’t move when the page is scrolled
H1
{position:absolute;
Top:20px;
Left:20px;
Right:20px;
Bottom:20px
}
Overflow property
Pre
{overflow:visible/hidden/scroll/auto;
Height:200px;
Width:200px
}
Visibility Property
H1{visibility:visible/hidden/collapse(only for table)
Layering a webpage
Z-index property
<html>
<head>
<style>
p
{background-color:blue;
position:absolute;
left:40px;
top:40px;
width:300px;
height:260px;
z-index:1
}
blockquote
{
background-color:yellow;
position:absolute;
left:80px;
top:80px;
width:300px;
height:200px;
z-index:2
}
</style>
</head>
<body>
<blockquote><font size=7>Do you ant to play hide and seek</font></blockquote>
<p><font size=7>count to ten</font></p>
</body>
</html>
Object referencing
The simplest way to reference an element is by its ID attribute.The element is represented
as an object,a nd its various HTML attributes become properties that can be manipulated
by scripting.
<html>
<head>
<script language=”javascript”>
function a1()
{
alert(p.innertext)
p.innertext=”thanks for coming”
}
</script>
</head>
<body onload=”a1()”>
<p id=”p”>welcome to our web page</p>
</body>
</html>
Filters
Microsoft has added a variety of multimedia filters and transitions that can be accessed
via a style sheet.The basic form of a filter rule is shown below:
Filtername Description
Alpha sets a uniform transparency level
Blur Creates the impression of moving at high speed
Chroma Makes a specific color transparent
DropShadow Creates a solid shadow of the object
FlipH Creates horizontal mirror image
FlipV Creates vertical mirror image
Glow Add radiance around the outside edges of the object
Grayscale Drops color information from the image
Invert Reverses the hue,saturation and brightness values
Light Projects a light source onto an object
Mask Creates a transparent mask from an object
Shadow Creates an offset solid
Wave Creates a sine wave distortion along the x-alix
Xray: Shows just the edges of the object
Example:
<html>
<head>
<style text=”text/css”>
.glow{
height:10;width:400;filter:glow(color=red,strength=4)
}
.blur{
height:10;width:400;filter:blur(add=1,direction=90,strength=10)
}
.dropshadow
{
height:10;width:400;filter:dropshadow(color=green,offx=2,offy=2,positive=1)
}
.fliph
{
height:10;width:400;filter:fliph()
}
.flipv
{
height:10;width:400;filter:flipv()
}
.shadow
{
height:10;width:400;filter:shadow(color:blue)
}
.wave
{
height:10;width:400;filter:wave(add=1,freq=4,lightstrength=50,phase=50,strength=10)
}
</style>
</head>
<body>
<div class=”blur”>This is a blur filter</div>
<div class=”dropshadow”>This is dropshadow</div>
<div class=”fliph”>This is the flip horizontal filter</div>
<div class=”flipv”>This is the flip vertical filter</div>
<div class=”glow”>This is a glow filter</div>
<div class=”shadow”>This is a shadow filter</div>
<div class=”wave”>This is a wave filter</div>
</body></html>