Professional Documents
Culture Documents
<tr>
<td class=”subtext”>
font-family: arial;
size: 2;
color: red;
background-color: #FFCCCC;
}
Selectors
declaration
p { color: red }
valu
selector
property e
Carrier tags
The <div> and <span> tags are particularly
useful in combination with class selectors.
Repeating options:
no-repeat, repeat-x, repeat-y
Position options:
top, center, bottom, or numerical
Margins and paddings
Margins and paddings
margin: 2px;
margin: 2px 4px 2px 4px;
margin: 2px 4px;
margin-top: 2px;
border-width: 1px;
border-color: #ccc;
border-style: solid
border: solid 1px #ccc;
Height and Width
height: 10px;
width: 300px;
width: 100% and height: 100% are possible for
items inside fixed width and height containers.
Caveat!
Floats
Floats
How to float?
#picture {
float: left;
width: 100px; (this is important)
}
#column1 {
Floating columns
float:left;
width: 33%;
}
#column2 {
float:left;
width: 33%;
}
#column3 {
Clearing floats
Make sure to clear floats when you want to
return to the normal block or inline flow.
<div id="picture">
<img src="bill.jpg" alt="Bill Gates">
</div>
<h1>Bill Gates</h1>
.clearfix {
clear:both;
Positioning
The Principle
Positioning
Absolute:
h1 {
position: absolute;
top: 100px;
left: 200px;
}
Positioning
Relative:
#item1 {
Positioning
position:relative;
left: 350px;
bottom: 150px;
}
#item2 {
position:relative;
left: 150px;
Layering
z-index
Hide / Show Elements
display: block;
display: inline;
display: inline-block;
Pseudo-classes
a:link
a:visited
a:hover
a:active
*:first-child
*:last-child
*:nth-child(2) do this every 2nd occurrence of
this element in its parent group.
PRACTICAL DEMO
Common Mistakes