Class Notes Css PDF
Class Notes Css PDF
semantics (the look and formatting) of a document written in a markup language. Its most
common application is to style web pages written in HTML and XHTML.
CSS is designed primarily to enable the separation of document content (written in HTML or
a similar markup language) from document presentation, including elements such as the
layout, colors, and fonts. This separation can improve content accessibility, provide more
flexibility and control in the specification of presentation characteristics, enable multiple
pages to share formatting, and reduce complexity and repetition in the structural content
(such as by allowing for tableless web design). CSS can also allow the same markup page to
be presented in different styles for different rendering methods, such as on-screen, in print,
by voice (when read out by a speech-based browser or screen reader) and on Braille-based,
tactile devices. It can also be used to allow the web page to display differently depending on
the screen size or device on which it is being viewed. While the author of a document
typically links that document to a CSS style sheet, readers can use a different style sheet,
perhaps one on their own computer, to override the one the author has specified.
CSS specifies a priority scheme to determine which style rules apply if more than one rule
matches against a particular element. In this so-called cascade, priorities or weights are
calculated and assigned to rules, so that the results are predictable.
A style sheet consists of a list of rules. Each rule or rule-set consists of one or more
selectors, and a declaration block. A declaration-block consists of a list of declarations in
braces. Each declaration itself consists of a property, a colon (:), and a value. If there are
multiple declarations in a block, a semi-colon (;) must be inserted to separate each
declaration. In CSS, selectors are used to declare which part of the markup a style applies to,
a kind of match expression. Selectors may apply to all elements of a specific type, to
elements specified by attribute, or to elements depending on how they are placed relative
to, or nested within, others in the document tree.
P Selector
Font-family : arial;
Color : blue;
}
CSS information can be provided from various sources. CSS style information can be in a
separate document or it can be embedded into an HTML document. Multiple style sheets
can be imported.
1
Inline styles, inside the HTML document, style information on a single element,
specified using the style attribute
Embedded or internal style, blocks of CSS information inside the <head> element of
HTML itself
External style sheets, i.e., a separate CSS file referenced from the document
P
{
Font-family:arial;
Font-size:medium;
2
Color:blue;
Text-align:justify;
}
H1
{
Font-family:arial black;
Background-color:blue;
Color:white;
}
Create another new document in notepad and create a html file with the following html
markup. To link an external css file, use <link> element of html within the <head> element.
<!doctype html>
<html>
<head>
<link rel=”stylesheet” type=”text/css” href=”MyStyle.css”/>
</head>
<body>
<h1> Heading </h1>
<p> This is a paragraph formatted with internal css style. </p>
</body>
</html>
Selector syntax
A simple selector is either a type selector or universal selector followed immediately by zero
or more attribute selectors, ID selectors, or pseudo-classes, in any order. The simple
selector matches if all of its components match.
The elements of the document tree that match a selector are called subjects of the selector.
A selector consisting of a single simple selector matches any element satisfying its
requirements. Prepending a simple selector and combinator to a chain imposes additional
matching constraints, so the subjects of a selector are always a subset of the elements
matching the last simple selector.
One pseudo-element may be appended to the last simple selector in a chain, in which case
the style information applies to a subpart of each subject.
3
Grouping
When several selectors share the same declarations, they may be grouped into a comma-
separated list.
In this example, we condense three rules with identical declarations into one. Thus,
h1 { font-family: sans-serif }
h2 { font-family: sans-serif }
h3 { font-family: sans-serif }
is equivalent to:
Universal selector
The universal selector, written "*", matches the name of any element type. It matches any
single element in the document tree. If the universal selector is not the only component of a
simple selector, the "*" may be omitted. For example:
Type selectors
A type selector matches the name of a document language element type. A type selector
matches every instance of the element type in the document tree.
h1 { font-family: sans-serif }
Descendant selectors
At times, authors may want selectors to match an element that is the descendant of
another element in the document tree (e.g., "Match those EM elements that are contained
4
by an H1 element"). Descendant selectors express such a relationship in a pattern. A
descendant selector is made up of two or more selectors separated by white space. A
descendant selector of the form "A B" matches when an element B is an arbitrary
descendant of some ancestor element A.
h1 { color: red }
em { color: red }
Although the intention of these rules is to add emphasis to text by changing its color, the
effect will be lost in a case such as:
We address this case by supplementing the previous rules with a rule that sets the text color
to blue whenever an EM occurs anywhere within an H1:
h1 { color: red }
em { color: red }
h1 em { color: blue }
is <EM>very</EM> important</SPAN></H1>
div * p
matches a P element that is a grandchild or later descendant of a DIV element. Note the
white space on either side of the "*" is not part of the universal selector; the white space is
a combinator indicating that the DIV must be the ancestor of some element, and that that
element must be an ancestor of the P.
The selector in the following rule, which combines descendant and attribute selectors,
matches any element that has the "href" attribute set and is inside a P that is itself inside a
DIV:
div p *[href]
5
Child selectors
A child selector matches when an element is the child of some element. A child selector is
made up of two or more selectors separated by ">".
The following rule sets the style of all P elements that are children of BODY:
div ol>li p
It matches a P element that is a descendant of an LI; the LI element must be the child of an
OL element; the OL element must be a descendant of a DIV. Notice that the optional white
space around the ">" combinator has been left out.
Thus, the following rule states that when a P element immediately follows a MATH element,
it should not be indented:
math + p { text-indent: 0 }
The next example reduces the vertical space separating an H1 and an H2 that immediately
follows it:
h1 + h2 { margin-top: -5mm }
The following rule is similar to the one in the previous example, except that it adds a class
selector. Thus, special formatting only occurs when H1 has class="opener":
Attribute selectors
CSS 2.1 allows authors to specify rules that match elements which have certain attributes
defined in the source document.
6
Matching attributes and attribute values
Attribute selectors may match in four ways:
[att]
Match when the element sets the "att" attribute, whatever the value of the attribute.
[att=val]
[att~=val]
Represents an element with the att attribute whose value is a white space-separated list of
words, one of which is exactly "val". If "val" contains white space, it will never represent
anything (since the words are separated by spaces). If "val" is the empty string, it will never
represent anything either.
[att|=val]
Represents an element with the att attribute, its value either being exactly "val" or
beginning with "val" immediately followed by "-". This is primarily intended to allow
language subcode matches (e.g., the hreflang attribute on the a element in HTML) as
described in BCP 47 or its successor.
Attribute values must be identifiers or strings. The case-sensitivity of attribute names and
values in selectors depends on the document language.
For example, the following attribute selector matches all H1 elements that specify the "title"
attribute, whatever its value:
In the following example, the selector matches all SPAN elements whose "class" attribute
has exactly the value "example":
Multiple attribute selectors can be used to refer to several attributes of an element, or even
several times to the same attribute.
Here, the selector matches all SPAN elements whose "hello" attribute has exactly the value
"Cleveland" and whose "goodbye" attribute has exactly the value "Columbus":
7
The following selectors illustrate the differences between "=" and "~=". The first selector will
match, for example, the value "copyright copyleft copyeditor" for the "rel" attribute. The
second selector will only match when the "href" attribute has the value
"http://www.nareshit.com/".
a[rel~="copyright"]
a[href="http://www.nareshit.com/"]
The following rule hides all elements for which the value of the "lang" attribute is "fr" (i.e.,
the language is French).
The following rule will match for values of the "lang" attribute that begin with "en",
including "en", "en-US", and "en-cockney":
Similarly, the following aural style sheet rules allow a script to be read aloud in different
voices for each role:
Class selectors
Working with HTML, authors may use the period (.) notation as an alternative to the ~=
notation when representing the class attribute. Thus, for HTML, div.value and
div[class~=value] have the same meaning. The attribute value must immediately follow the
"period" (.).
For example, we can assign style information to all elements with class~="pastoral" as
follows:
or just
8
Given these rules, the first H1 instance below would not have green text, while the second
would:
<H1>Not green</H1>
For example, the following rule matches any P element whose "class" attribute has been
assigned a list of space-separated values that includes "pastoral" and "marine":
This rule matches when class="pastoral blue aqua marine" but does not match for
class="pastoral blue".
ID selectors
Document languages may contain attributes that are declared to be of type ID. What makes
attributes of type ID special is that no two such attributes can have the same value;
whatever the document language, an ID attribute can be used to uniquely identify its
element. In HTML all ID attributes are named "id"; XML applications may name ID attributes
differently, but the same restriction applies.
The following ID selector matches the H1 element whose ID attribute has the value
"chapter1":
In the following example, the style rule matches the element that has the ID value "z98y".
The rule will thus match for the P element:
<head>
<title>match p</title>
<style type="text/css">
9
</style>
</head>
<body>
</body>
In the next example, however, the style rule will only match an H1 element that has an ID
value of "z98y". The rule will not match the P element in this example:
<head>
<title>match h1 only</title>
<style type="text/css">
</style>
</head>
<body>
</body>
ID selectors have a higher specificity than attribute selectors. For example, in HTML, the
selector #p123 is more specific than [id=p123] in terms of the cascade.
If an element has multiple ID attributes, all of them must be treated as IDs for that element
for the purposes of the ID selector.
10
Pseudo-elements create abstractions about the document tree beyond those specified by
the document language. For instance, document languages do not offer mechanisms to
access the first letter or first line of an element's content. CSS pseudo-elements allow style
sheet designers to refer to this otherwise inaccessible information. Pseudo-elements may
also provide style sheet designers a way to assign style to content that does not exist in the
source document (e.g., the :before and :after pseudo-elements give access to generated
content).
Some pseudo-classes are mutually exclusive, while others can be applied simultaneously to
the same element. In case of conflicting rules, the normal cascading order determines the
outcome.
Pseudo-classes
:first-child pseudo-class
The :first-child pseudo-class matches an element that is the first child element of some
other element.
In the following example, the selector matches any P element that is the first child of a DIV
element. The rule suppresses indentation for the first paragraph of a DIV:
This selector would match the P inside the DIV of the following fragment:
<div class="note">
11
<p> the first p inside the note.
</div>
<div class="note">
<h2>note</h2>
</div>
The following rule sets the font weight to 'bold' for any EM element that is some
descendant of a P element that is a first child:
a:first-child /* Same */
The :link pseudo-class applies for links that have not yet been visited.
The :visited pseudo-class applies once the link has been visited by the user.
The document language determines which elements are hyperlink source anchors. For
example, in HTML4, the link pseudo-classes apply to A elements with an "href" attribute.
Thus, the following two CSS 2.1 declarations have similar effect:
12
<A class="external" href="http://out.side/">external link</A>
The :hover pseudo-class applies while the user designates an element (with some pointing
device), but does not activate it. For example, a visual user agent could apply this pseudo-
class when the cursor (mouse pointer) hovers over a box generated by the element. User
agents not supporting interactive media do not have to support this pseudo-class. Some
conforming user agents supporting interactive media may not be able to support this
pseudo-class (e.g., a pen device).
The :active pseudo-class applies while an element is being activated by the user. For
example, between the times the user presses the mouse button and releases it.
The :focus pseudo-class applies while an element has the focus (accepts keyboard events or
other forms of text input).
CSS does not define which elements may be in the above states, or how the states are
entered and left. Scripting may change whether elements react to user events or not, and
different devices and UAs may have different ways of pointing to, or activating elements.
CSS 2.1 does not define if the parent of an element that is ':active' or ':hover' is also in that
state.
User agents are not required to reflow a currently displayed document due to pseudo-class
transitions. For instance, a style sheet may specify that the 'font-size' of an :active link
should be larger than that of an inactive link, but since this may cause letters to change
position when the reader selects the link, a UA may ignore the corresponding style rule.
13
a:active { color: lime } /* active links */
Note that the A:hover must be placed after the A:link and A:visited rules, since otherwise
the cascading rules will hide the 'color' property of the A:hover rule. Similarly, because
A:active is placed after A:hover, the active color (lime) will apply when the user both
activates and hovers over the A element.
The last selector matches A elements that are in pseudo-class :focus and in pseudo-class
:hover.
The following rules set the quotation marks for an HTML document that is either in
Canadian French or German:
The second pair of rules actually set the 'quotes' property on Q elements according to the
language of its parent. This is done because the choice of quote marks is typically based on
14
the language of the element around the quote, not the quote itself: like this piece of French
“à l'improviste” in the middle of an English text uses the English quotation marks.
Pseudo-elements
Pseudo-elements behave just like real elements in CSS with the exceptions described below
and elsewhere.
The above rule means "change the letters of the first line of every paragraph to uppercase".
However, the selector "P:first-line" does not match any real HTML element. It does match a
pseudo-element that conforming user agents will insert at the beginning of every
paragraph.
Note that the length of the first line depends on a number of factors, including the width of
the page, the font size, etc. Thus, an ordinary HTML paragraph such as:
paragraph.</P>
15
might be "rewritten" by user agents to include the fictional tag sequence for :first-line. This
fictional tag sequence helps to show how properties are inherited.
paragraph.</P>
If a pseudo-element breaks up a real element, the desired effect can often be described by a
fictional tag sequence that closes and then re-opens the element. Thus, if we mark up the
previous paragraph with a SPAN element:
paragraph.</P>
the user agent could simulate start and end tags for SPAN when inserting the fictional tag
sequence for :first-line.
paragraph.</P>
16
The :first-line pseudo-element can only be attached to a block container element.
The "first formatted line" of an element may occur inside a block-level descendant in the
same flow (i.e., a block-level descendant that is not positioned and not a float). E.g., the first
line of the DIV in <DIV><P>This line...</P></DIV> is the first line of the P (assuming that both
P and DIV are block-level).
The first line of a table-cell or inline-block cannot be the first formatted line of an ancestor
element. Thus, in <DIV><P STYLE="display: inline-block">Hello<BR>Goodbye</P>
etcetera</DIV> the first formatted line of the DIV is not the line "Hello".
Note that the first line of the P in this fragment: <p><br>First... does not contain any letters
(assuming the default style for BR in HTML 4). The word "First" is not on the first formatted
line.
These are the properties that apply to :first-letter pseudo-elements: font properties, 'text-
decoration', 'text-transform', 'letter-spacing', 'word-spacing' (when appropriate), 'line-
height', 'float', 'vertical-align' (only if 'float' is 'none'), margin properties, padding properties,
border properties, color property, background properties.
This example shows a possible rendering of an initial cap. Note that the 'line-height' that is
inherited by the first-letter pseudo-element is 1.1, but the UA in this example has computed
the height of the first letter differently, so that it does not cause any unnecessary space
between the first two lines. Also note that the fictional start tag of the first letter is inside
the SPAN, and thus the font weight of the first letter is normal, not bold as the SPAN:
p { line-height: 1.1 }
...
17
<p><span>Het hemelsche</span> gerecht heeft zich ten lange lesten<br>
The following CSS 2.1 will make a drop cap initial letter span about two lines:
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
in the economist.</p>
</body>
</html>
18
The fictional tag sequence is:
<p>
<span>
<p:first-letter>
</p:first-letter>he first
</span>
</p>
Note that the :first-letter pseudo-element tags abut the content (i.e., the initial character),
while the :first-line pseudo-element start tag is inserted right after the start tag of the block
element.
In order to achieve traditional drop caps formatting, user agents may approximate font
sizes, for example to align baselines. Also, the glyph outline may be taken into account when
formatting.
Punctuation (i.e, characters defined in Unicode in the "open" (Ps), "close" (Pe), "initial" (Pi).
"final" (Pf) and "other" (Po) punctuation classes), that precedes or follows the first letter
should be included, as in:
The ':first-letter' also applies if the first letter is in fact a digit, e.g., the "6" in "67 million
dollars is a lot of money."
The :first-letter pseudo-element can be used with all such elements that contain text, or
that have a descendant in the same flow that contains text. A UA should act as if the
fictional start tag of the first-letter pseudo-element is just before the first text of the
element, even if that first text is in a descendant.
19
Here is an example. The fictional tag sequence for this HTML fragment:
<div>
is:
<div>
The first letter of a table-cell or inline-block cannot be the first letter of an ancestor
element. Thus, in <DIV><P STYLE="display: inline-block">Hello<BR>Goodbye</P>
etcetera</DIV> the first letter of the DIV is not the letter "H". In fact, the DIV does not have
a first letter.
The first letter must occur on the first formatted line. For example, in this fragment:
<p><br>First... the first line does not contain any letters and ':first-letter' does not match
anything (assuming the default style for BR in HTML 4). In particular, it does not match the
"F" of "First."
If an element is a list item ('display: list-item'), the ':first-letter' applies to the first letter in
the principal box after the marker. UAs may ignore ':first-letter' on list items with 'list-style-
position: inside'. If an element has ':before' or ':after' content, the ':first-letter applies to the
first letter of the element including that content.
E.g., after the rule 'p:before {content: "Note: "}', the selector 'p:first-letter' matches the "N"
of "Note".
Some languages may have specific rules about how to treat certain letter combinations. In
Dutch, for example, if the letter combination "ij" appears at the beginning of a word, both
letters should be considered within the :first-letter pseudo-element.
If the letters that would form the first-letter are not in the same element, such as "'T" in
<p>'<em>T..., the UA may create a first-letter pseudo-element from one of the elements,
both elements, or simply not create a pseudo-element.
Similarly, if the first letter(s) of the block are not at the start of the line (for example due to
bidirectional reordering), then the UA need not create the pseudo-element(s).
The following example illustrates how overlapping pseudo-elements may interact. The first
letter of each P element will be green with a font size of '24pt'. The rest of the first
formatted line will be 'blue' while the rest of the paragraph will be 'red'.
20
p:first-letter { color: green; font-size: 200% }
Assuming that a line break will occur before the word "ends", the fictional tag sequence for
this fragment might be:
<P>
<P:first-line>
<P:first-letter>
</P:first-line>
</P>
Note that the :first-letter element is inside the :first-line element. Properties set on :first-
line are inherited by :first-letter, but are overridden if the same property is set on :first-
letter.
When the :first-letter and :first-line pseudo-elements are applied to an element having
content generated using :before and :after, they apply to the first letter or line of the
element including the generated content.
21
Animation Properties
Background Properties
22
background-attachment Sets whether a background image is fixed or 1
scrolls with the rest of the page
23
border-left Sets all the left border properties in one declaration 1
24
border-bottom-left- Defines the shape of the border of the bottom-left 3
radius corner
box-decoration-break 3
25
Box Properties
Color Properties
26
Content for Paged Media Properties
string-set 3
27
Dimension Properties
28
box-ordinal-group Specifies the display order of the child elements of a 3
box
Font Properties
29
Generated Content Properties
Grid Properties
30
Hyperlink Properties
Linebox Properties
drop-initial-after-adjust Sets the alignment point of the drop initial for the 3
primary connection point
drop-initial-after-align Sets which alignment line within the initial line box is 3
used at the primary connection point with the initial
letter box
31
drop-initial-before- Sets the alignment point of the drop initial for the 3
adjust secondary connection point
drop-initial-before- Sets which alignment line within the initial line box is 3
align used at the secondary connection point with the
initial letter box
line-stacking-strategy Sets the line stacking strategy for stacked line boxes 3
within a containing block element
List Properties
32
list-style-image Specifies an image as the list-item marker 1
Margin Properties
Marquee Properties
33
Multi-column Properties
Padding Properties
34
padding-left Sets the left padding of an element 1
Positioning Properties
35
clip Clips an absolutely positioned element 2
Print Properties
36
page-break-before Sets the page-breaking behavior before an element 2
Ruby Properties
ruby-align Controls the text alignment of the ruby text and ruby 3
base contents relative to each other
Speech Properties
37
stream
38
Table Properties
Text Properties
39
block
unicode-bidi 2
40
word-break Specifies line breaking rules for non-CJK scripts 3
Transition Properties
41
transition-duration Specifies how many seconds or milliseconds a 3
transition effect takes to complete
User-interface Properties
42
outline-offset Offsets an outline, and draws it beyond the border 3
edge
Examples
1. The following example demonstrates how to use background image paroperties of css
<!doctype html>
<html>
<head>
<style>
body
background-image:url(e:/images/garden.jpg);
background-repeat:no-repeat;
background-size:200px 200px;
background-position:center center;
background-attachment:fixed;
</style>
</head>
<body>
<h1> Provide Text in the body to make the page scrollable </h1>
</body>
</html>
43
2. The following example animates a div element and moves it right and left with
animation properties of css 3
<!doctype html>
<html>
<head>
<style>
div
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove 5s 2;
@keyframes mymove
from {left:0px;}
to {left:200px;}
from {left:0px;}
to {left:200px;}
</style>
44
</head>
<body>
<div></div>
</body>
</html>
3. The following example animates a div element and moves it right then down then left
and finally top with animation properties of css 3
<!doctype html>
<html>
<head>
<style>
div
width:100px;
height:100px;
background:red;
position:relative;
animation-name:myfirst;
animation-duration:5s;
animation-timing-function:linear;
animation-delay:2s;
animation-iteration-count:infinite;
animation-direction:alternate;
animation-play-state:running;
/* Firefox: */
-moz-animation-name:myfirst;
45
-moz-animation-duration:5s;
-moz-animation-timing-function:linear;
-moz-animation-delay:2s;
-moz-animation-iteration-count:infinite;
-moz-animation-direction:alternate;
-moz-animation-play-state:running;
-webkit-animation-name:myfirst;
-webkit-animation-duration:5s;
-webkit-animation-timing-function:linear;
-webkit-animation-delay:2s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-direction:alternate;
-webkit-animation-play-state:running;
/* Opera: */
-o-animation-name:myfirst;
-o-animation-duration:5s;
-o-animation-timing-function:linear;
-o-animation-delay:2s;
-o-animation-iteration-count:infinite;
-o-animation-direction:alternate;
-o-animation-play-state:running;
@keyframes myfirst
46
25% {background:yellow; left:200px; top:0px;}
47
75% {background:green; left:0px; top:200px;}
</style>
</head>
<body>
<div></div>
</body>
</html>
4. The following example rotates an image when mouse is over the image with
animation properties of css 3
<!doctype html>
<html>
<head>
<style>
@-webkit-keyframes spin
to { -webkit-transform: rotate(360deg);}
@-moz-keyframes spin {
to { -moz-transform: rotate(360deg);}
@-o-keyframes spin {
48
to { -o-transform: rotate(360deg);}
@-ms-keyframes spin {
to { -ms-transform: rotate(360deg);}
img
width:250px;
height:250px;
align:center;
img:hover
</style>
</head>
<body>
<img src="e:\images\garden.jpg"/>
</body>
</html>
49
5. The following example changes background of the page from red to yellow using
animation properties of css 3
<!doctype html>
<html>
<head>
<style>
body
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mycolor 5s infinite;
-webkit-animation:mymove 5s infinite; /*Safari and Chrome*/
}
@keyframes mycolor
{
from {background: red;}
to {background: yellow;}
}
50
6. The following example demonstrates how to design a page as follows using css
/* BASIC */
body {
font: 62.7% Verdana, Arial, Helvetica, sans-serif;
}
a img {
border: none;
}
/* LAYOUT */
51
#banner {
background: url(images/banner.png) no-repeat right top;
height: 90px;
}
/* NAVIGATION */
#mainNav li {
list-style: none;
display: inline;
}
#mainNav a {
text-decoration: none;
color: #000000;
font-size: 1.1em;
text-transform: uppercase;
border-bottom: 1px dashed #999999;
display: block;
padding: 7px 5px 7px 30px;
background: #E7E7E7 url(images/link.png) no-repeat left center;
}
a#homeLink {
background-image: url(images/home.png);
background-repeat: no-repeat;
background-position: left center;
}
#logo {
display: none;
}
#mainNav ul {
border-top: 1px dashed #999999;
margin-top: 20px;
margin-bottom: 20px;
}
#mainNav a:hover {
background: #B2F511 url(images/go.png) no-repeat left center;
padding-right: 15px;
padding-left: 30px;
font-weight: bold;
52
}
#nav p {
color: #ED6733;
padding-right: 5px;
padding-left: 5px;
}
#nav a {
text-decoration: none;
color: #666666;
}
/* BANNER STYLES */
#banner img {
float: left;
}
#banner ul {
margin: 0px;
padding: 0px;
list-style: none;
}
#banner li {
display: inline;
float: right;
margin-right: 5px;
padding-bottom: .5em; /* to display bottom border on links in IE */
53
}
#sitetools li a {
font-size: 1em;
text-decoration: none;
color: #FFFFFF;
line-height: 2em;
background: #1B3A89;
padding: 5px;
height: 2em;
border: 1px solid #4D69B0;
font-weight: bold;
}
#sitetools li a:hover {
color: #10214E;
background: #DCE5FF;
}
/* MAIN */
#main a {
text-decoration: none;
border-bottom: 1px dashed #B2F511;
color: #152D6A;
}
#main h1 {
color: #152D6A;
margin-top: 15px;
margin-bottom: 5px;
border-bottom: 2px solid #B2F511;
font: normal 2.7em Impact, "Arial Narrow", sans-serif;
text-transform: uppercase;
letter-spacing: 1px;
word-spacing: 5px;
background: url(images/feature_bug.png) no-repeat top right;
}
#main h2 {
font: normal 2em Georgia, "Times New Roman", Times, serif;
margin-top: 15px;
54
margin-bottom: 3px;
color: #152D6A;
}
#main p {
font-size: 1.25em;
margin-bottom: 5px;
}
/* NEWS */
#news .story {
background: url(images/bg_story.png) repeat-y;
color: #FFFFFF;
padding: 5px 5px;
border-bottom: 1px dashed #AAEB11;
display: block;
text-decoration: none;
line-height: 110%;
}
#news span.title {
font-size: 1.1em;
font-weight: bold;
display: block;
line-height: 120%;
color: #FFCC00;
}
#news a.story:hover {
color: #4A761D;
background: url(images/bg_story_high.png);
}
* html #news a {
height: 1px;
}
55
#news h2 {
background: #B2F511 url(images/bg_newshead.png) no-repeat;
color: #333333;
font-size: 2em;
text-transform: uppercase;
padding-top: 25px;
padding-bottom: 0px;
padding-left: 5px;
}
#news h2 span {
background: url(images/down.png) no-repeat;
position: absolute;
right: 10px;
height: 48px;
width: 48px;
top: 4px;
z-index: 10;
}
/* ADVERTISING */
div.natEx {
text-align: center;
margin-top: 25px;
font-weight: bold;
}
.natEx p {
margin-bottom: 5px;
}
#news a.story:hover span.title {
color: #000000;
}
<html>
<head>
56
<link href="global.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body
margin: 0;
padding: 0;
#wrapper
width: 760px;
margin-right: auto;
margin-left: auto;
#main
float: left;
width: 419px;
margin-left: 160px;
padding-left: 10px;
57
#news
float: right;
width: 160px;
#nav
float: left;
width: 160px;
margin-left: -590px;
#legal
clear: both;
margin-right: 160px;
font-weight: bold;
color: #666666;
</style>
</head>
<body id="feature">
<div id="wrapper">
<div id="banner">
58
<img src="e:\images\garden.jpg" alt="CosmoFarmer" width="287" height="53"
border="0" />
</a>
</p>
<ul id="sitetools">
</ul>
</div>
<div id="main">
<h1>Bathtub Hydroponics</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure. <a href="http://www.hydroponicsonline.com/">You'll find more
information here
</a>.
</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure.</p>
59
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure. </p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure. </p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
60
suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
vel eum iriure.</p>
</div>
<div id="news">
<h2>News</h2>
The stars are aligned in your favor. Next month? Not so much. </a>
Sod or Seed?</span>
Should you grow grass from scratch or have an expert install a beautiful, already
grown, lucious bed of green in your living room? </a>
</div>
<div id="nav">
61
<div id="mainNav">
<ul>
<li><a href="#">Experts</a></li>
<li><a href="#">Quiz</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Horoscopes</a></li>
</ul>
</div>
<div class="natEx">
</div>
<p> </p>
</div>
</div>
</body>
</html>
62
7. The following example demonstrates how to design a page with a form as follows
using css
/* BASIC */
body
margin: 0;
background-color: #FFFFFF;
p,h1,h2,h3,h4,h5,h5,ol,ul
margin: 0px;
63
padding: 0px;
br.clear
height:1px;
clear:both;
line-height: 1px;
background-color: #00CC33;
/* LAYOUT */
#wrapper
width: 760px;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #999999;
#main
float: left;
width: 424px;
#subNav
64
{
width: 150px;
float: left;
background-color: #FBEF99;
#banner
background-image: url(images/bg/banner_bg.jpg);
background-repeat: repeat-x;
background-position:
left top;
width: 759px;
#announce
float: left;
width: 166px;
margin-top: 3px;
margin-left: 3px;
line-height: 95%;
margin-right: 3px;
#copyright
65
{
clear: both;
margin-left: 150px;
border-right:none;
font-size: 12px;
padding-left: 6px;
/* BANNER STYLES */
#background
background-image: url(images/bg/banner_flower.jpg);
background-repeat: no-repeat;
#banner p.logo
height: 70px;
text-indent: -5000px;
#nav
margin-top: 10px;
margin-bottom: 0px;
66
}
#nav li
list-style-type: none;
padding: 0px;
margin: 0;
float: left;
#nav a
display: block;
font-size: 11px;
color: #D6ECAE;
text-decoration: none;
background-color: #294E56;
width: 8em;
margin-left: 2px;
font-weight: bold;
margin-bottom: 2px;
#nav a:hover
background: #73AFB7;
67
border-right: 1px solid #14556B;
color: #FBEF99;
background: #73AFB7;
color: #FBEF99;
#main h1 {
color: #5F9794;
/* ANNOUNCEMENT STYLES */
#announce h2
font-size: 14px;
#announce a
font-size: 12px;
68
display: block;
text-decoration: none;
color: #102536;
#announce .title
font-weight: bold;
display: block;
#announce a:hover
background-color: #5F9794;
color: #FBEF99
#announce ul
list-style:none;
#announce li
display: inline;
/* HOME */
69
/* no left sidebar--stretch main entire distance */
#home #main
margin-left: 0;
width: 577px;
#home #copyright
margin-left: 0;
font-style: italic;
#subNav li a
font-size: 12px;
text-decoration: none;
display: block;
width: 138px;
color: #14556B;
#subNav li a:hover
70
background: url(images/bg/side_nav_bg.jpg);
color: #102536;
.col2 #announce
float: left;
margin-bottom: 10px;
.col2 #main
float: right;
border-right: none;
width: 573px;
.col2 #copyright
margin-left: 0px;
#main h2
font-size: 1.2em;
margin-top: 15px;
color: #666666;
#main #subForm p
71
margin-top: 10px;
margin-bottom: 10px;
#main p.privacy
color: #73AFB7;
margin-top: 25px;
margin-bottom: 50px;
font-size: 0.85em;
Create a html page as follows for designing the page with a form
<!DOCTYPE html>
<html>
<head>
<![endif]-->
<style type="text/css">
#subForm
font-size: .8em;
#subForm .label
72
float: left;
width: 230px;
margin-right: 10px;
text-align: right;
font-weight: bold;
clear: left;
#subscribe
margin-left: 240px;
background-color: #CBD893;
#refer
background-color: #FBEF99;
font-size: .9em;
width: 300px;
margin-top: -2px;
73
#name:focus,
#email:focus,
#comments:focus,
#refer:focus
background-color: #FDD041;
</style>
</head>
<div id="wrapper">
<div id="banner">
<div id="nav">
<ul>
<li><a href="/horoscopes/index.html"
id="horoscopeLink">Horoscopes</a></li></ul>
</div>
</div>
74
</div>
<div id="main">
<p>
<label>
</p>
<p>
<option value="1">Friend</option>
</select>
75
</p>
<p>
</p>
<p>
</p>
</form>
</p>
</div>
<div id="announce">
<ul>
76
<li><a href="#"><span class="title">Lorem Ipsum </span>Lorem ipsum dolor site
amet.</a></li>
</ul>
</div>
</div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
.threecolumn
-moz-column-count:3; /* Firefox */
column-count:3;
77
-moz-column-gap:40px; /* Firefox */
column-gap:40px;
-moz-column-width:200px; /* Firefox */
-ms-column-width:200px;
h2
-webkit-column-span:1; /* Chrome */
column-span:1;
-ms-column-span:1;
</style>
</head>
<body>
<div class="threecolumn">
<h2> This Heading Spans On All Columns In The page This Heading Spans On All
Columns In The page</h2>
This is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
78
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3. This is a three column layout created for the
page with css 3. This is a three column layout created for the page with css 3. This
is a three column layout created for the page with css 3. This is a three column
layout created for the page with css 3.
</div>
</body>
</html>
79