Ip Chapter Four
Ip Chapter Four
CSS
Intro
If all pages on your site are linked to the same external
style sheet, then one simple change to the style sheet
will change all elements across the site.
If you then want to change those instructions (for
example, the size of a document heading), you need
not change every page manually. You need only change
a line in the style sheet file, then all your headings will
change their appearance to conform to the style sheet.
This technology can save a great deal of development
and maintenance time, as well as make a more
consistent, accessible interface.
Introduction
CSS stands for Cascading Style Sheets
Styles define how to display HTML elements
(describing the presentation of Web pages, including
colors, layout, fonts, etc….)
It is design to enable the separation of document
content from document presentation.
enable multiple HTML pages to share formatting by
specifying the relevant CSS in a separate .css file.
reduce complexity and repetition in the structural
content.
Cont.….
A CSS rule set consists of a selector and a declaration block
h2 {
text-align: center;
color: red;
}
p{
text-align: center;
color: red;
}
h1, h2, p {
text-align: center;
color: red;
}
Cont.….
Three Ways to Insert CSS
here are three ways of inserting a style sheet:
External style sheet
An external style sheet is ideal when the style is applied to many
pages.
Each page must include a link to the style sheet with the <link> tag.
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Internal style sheet
An internal style sheet should be used when a single document has a
unique style.
Inline style
Cont.…..
CSS Background
CSS background properties are used to define the
background effects of an element.
CSS properties used for background effects:
background-color
background-color: #b0c4de;
a HEX value - like "#ff0000"
an RGB value - like "rgb(255,0,0)"
a color name - like "red"
background-image
background-image: url("paper.gif");
Cont.…..
background-repeat
Repeat the background image both horizontally and vertically.
body {
background-image: url("gradient_bg.png");
background-repeat: repeat-x;
}
background-attachment
Sets whether a background image is fixed or scrolls with the rest of the
page.
background-attachment: scroll/fixed/
background-position
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
Cont.…..
Background - Shorthand property
The shorthand property for background is simply
"background“
body {
background: #ffffff url("img_tree.png") no-repeat right top;
}
When using the shorthand property the order of the
property values is:
background-color
background-image
background-repeat
background-attachment
background-position
Cont.……
CSS Text
Text Color
The color property is used to set the color of the text.
With CSS, a color is most often specified by:
a HEX value - like "#ff0000"
an RGB value - like "rgb(255,0,0)"
a color name - like "red“
Color: ff0000
Text Alignment
The text-align property is used to set the horizontal alignment of a
text.
Text can be centered, or aligned to the left or right, or justified.
o text-align: center
Cont.…..
Text Decoration
The text-decoration property is used to set or remove
decorations from text.
text-decoration: none; overline; underline; throghline;
Text Transformation
The text-transform property is used to specify uppercase and
lowercase letters in a text.
text-transform: uppercase; lowercase; capitalize;
Text Indentation
The text-indent property is used to specify the indentation of the
first line of a text.
text-indent: 50px;
/* visited link */
a:visited {
color: #00FF00;
}
/* selected link */
a:active {
color: #0000FF;
}