CSS For Page Layout: Key Concepts
CSS For Page Layout: Key Concepts
Key Concepts
Content
Text & web page
elements in the
container
Padding
Area between the
content and the border
Border
Between the padding
and the margin
Margin
Determines the empty
space between the
element and adjacent
elements
Normal Flow
Figure 6.5
Figure 6.6
Relative Positioning
h1 { background-color:#cccccc;
padding:5px;
color: #000000;
}
#myContent { position: relative;
left:30px;
font-family:Arial,sans-serif;
}
Absolute Positioning
Precisely specifies the location of an
element in the browser window
h1 { background-color:#cccccc;
padding:5px;
color: #000000;
}
#content {position: absolute;
left:200;
top:100;
font-family:Arial,sans-serif;
width:300;
}
float Property
h1 { background-color:#cccccc;
padding:5px;
color: #000000;
}
p { font-family:Arial,sans-serif;
}
#yls {float:right;
margin: 0 0 5px 5px;
border: solid;
}
The h2 text
is displayed
in normal
flow.
clear Property
Useful to clear or
terminate a float
Values are left, right,
and both
The
background
does not
extend as far
as youd
expect.
overflow Property
overflow: auto;
was applied to the div
that contains the image
and paragraph. Now the
background extends and
the h2 text displays
AFTER the floated image.
Display Property
display:block ;
The element is rendered as a block element even if it is
actually an inline element,
such as a hyperlink.
display:inline;
The element will be rendered as an inline element even
if it is actually a block element such as a <li>.
Z-Index Property
13
Two Column
Page Layout
Left-column navigation
float: left;
width:100px;
Right-column content
margin-left: 100px;
body {margin: 0;
font-family: Verdana, Arial, sans-serif; }
Two Column
Page Layout
min-width :800px; }
#leftcolumn { float: left;
width: 100px; }
#rightcolumn { margin-left :100px;
background-color :#ffffff;
color :#000000; }
16
Configure a class:
If the style may apply to more than one element on a
page
Use the . (dot) notation in the style sheet.
Use the class attribute in the XHTML.
Configure an id:
If the style is specific to only one element on a page
Use the # notation in the style sheet.
Use the id attribute in the XHTML.
17
Source: http://code.google.com/webstats
18
http://glish.com/css/
Large collection of CSS page layouts and links to tutorials
http://www.websitetips.com/css/index.shtml
Comprehensive list of tutorials and CSS-related sites
http://www.meyerweb.com/eric/css/
The web site of Eric Meyer, a leading-edge web developer
http://www.w3.org/Style/CSS/learning
W3Cs list of CSS resources
http://www.bluerobot.com/web/layouts/
A reservoir of CSS page layouts
http://www.blooberry.com/indexdot/css/
CSS syntax reference list
20