Css PDF
Css PDF
Selector
TH {color: red;}.
The Selector indicates the element to which the
rule is applied.
The Declaration determines the property values of
a selector.
Value
Property
P {color: red;}
CSS declarations always ends with a semicolon, and declaration groups are
surrounded by curly brackets:
p {color:red;text-align:center;}To make the CSS more readable, you can put one declaration
on each line, like this:
Example
p { color:red; text-align:center;
}
CSS Comments
A CSS comment begins with "/*", and ends with "*/", like this:
/*This is a comment*/ p
{
text-align:center;
/*This is another
comment*/ color:black;
font-family:arial;
}
The id and class Selectors
The id Selector
#para1
{
text-align:center;
color:red;
}
hr {color:red;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
Internal Style Sheet
body {background-image:url('paper.gif');}
body
{
background-image:url('gradient2.png');
background-repeat:repeat-x;
}
body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
}
body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
background-position:top right;
}
in short it can be written as:
body {background:#ffffff url('img_tree.png') no-
repeat top right;}
body {color:blue;}
h1 {color:#00ff00;} h2
{color:rgb(255,0,0);}
h1 {text-align:center;}
p.date {text-align:right;}
p.main {text-align:justify;}
A
{
text-decoration:none;
}
p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}
p { text-
indent:50px;}
Font Family
The font family of a text is set with the font-family
property.
The font-family property should hold several font names
as a "fallback" system. If the browser does not support
the first font, it tries the next font.
p{font-family:"Times New Roman", Times, serif;}
p.normal {font-style:normal;}
p.italic {font-style:italic;}
p.oblique {font-style:oblique;}
h1 {font-size:40px;} h2 {font-size:30px;} p {font-
size:14px;}
Set Font Size With Em
To avoid the resizing problem with Internet Explorer, many
developers use em instead of pixels.
The em size unit is recommended by the W3C.
1em is equal to the current font size. The default text size in
browsers is 16px. So, the default size of 1em is 16px.
The size can be calculated from pixels to em using this
formula: pixels/16=em
Example
h1 {font-size:2.5em;} /* 40px/16=2.5em */ h2 {font-
size:1.875em;} /* 30px/16=1.875em */ p {font-size:0.875em;} /*
14px/16=0.875em */
Styling Links
Links can be style with any CSS property (e.g. color, font-family,
backgroundcolor).
Special for links are that they can be styled differently depending on what state
they are in.
The four links states are:
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user mouses over it
a:active - a link the moment it is clicked
Example
a:link {color:#FF0000;} /* unvisited link */ a:visited {color:#00FF00;} /* visited
link */ a:hover {color:#FF00FF;} /* mouse over link */ a:active {color:#0000FF;} /*
selected link */
<body>
<p>This is a paragraph with no specified padding.</p>
<p class="padding">This is a paragraph with specified paddings.</p>
</body>
</html>
<html>
<head>
<style type="text/css">
h1,h2,p
{
color:green;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<h2>Smaller heading!</h2>
<p>This is a paragraph.</p>
</body>
</html>
<html>
<head>
<style type="text/css">
p
{
color:blue;
text-align:center;
}
.marked p
{
color:white;
}
</style>
</head>
<body>
<p>This is a blue, center-aligned paragraph.</p>
<div class="marked">
<p>This p element should not be blue.</p>
</div>
</body>
</html>
<html>
<head>
<style type="text/css">
h1.hidden {visibility:hidden;}
</style>
</head>
<body>
<h1>This is a visible heading</h1>
<h1 class="hidden">This is a hidden heading</h1>
<p>Notice that the hidden heading still takes up space.</p>
</body>
</html>
Output:
Browser compatibility
Browsers have varying levels of compliance with
Style Sheets. This means that some Style Sheet
features are supported and some aren't.
Thankyou……