Draw A Line Around An Element, Outside The Border Edge (Outline)
Draw A Line Around An Element, Outside The Border Edge (Outline)
Draw a line around an element, outside the border edge (outline) (Does not work in IE)
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
<p>Some text.</p>
</body>
</html>
Set the style of an outline (Does not work in IE)
<html>
<head>
<style type="text/css">
{
border: red solid thin;
</style>
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
outline-style: solid;
outline-color: #00ff00
</style>
</head>
<body>
<p>Some text.</p>
</body>
</html>
Set the width of an outline (Does not work in IE)
<html>
<head>
<style type="text/css">
p.one
outline-style: solid;
outline-width: thick
p.two
outline-style: solid;
outline-width: 2px
</style>
</head>
<body>
</body>
</html>
Margin
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
</body>
</html>
Set the top margin of a text using a cm value
Set the top margin of a text using a percent value
<html>
<head>
<style type="text/css">
p.topmargin
margin-top: 25%
</style>
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
<table border="1">
<tr>
<td class="test1">
</td>
</tr>
</table>
<br />
<table border="1">
<tr>
<td class="test2">
This tablecell has a top and bottom padding of 0.5cm and a left and right padding of 2.5cm.
</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<style type="text/css">
td {padding-left: 2cm}
</style>
</head>
<body>
<table border="1">
<tr>
<td>
This is a tablecell with a left padding. This is a tablecell with a left padding.
</td>
</tr>
</table>
</body>
</html>
Table
<html>
<head>
<style type="text/css">
table.one
table-layout: automatic
}
table.two
table-layout: fixed
</style>
</head>
<body>
<tr>
<td width="20%">1000000000000000000000000000</td>
<td width="40%">10000000</td>
<td width="40%">100</td>
</tr>
</table>
<br />
<tr>
<td width="20%">1000000000000000000000000000</td>
<td width="40%">10000000</td>
<td width="40%">100</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<style type="text/css">
table
border-collapse: separate;
empty-cells: show
</style>
</head>
<body>
<table border="1">
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td></td>
</tr>
</table>
</body>
</html>
<html>
<head>
<style type="text/css">
table.coll
border-collapse: collapse
table.sep
border-collapse: separate
</style>
</head>
<body>
<table class="coll" border="1">
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
<br />
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<style type="text/css">
table.one
border-collapse: separate;
border-spacing: 10px
table.two
border-collapse: separate;
</style>
</head>
<body>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
<br />
<tr>
<td>Cleveland</td>
<td>Brown</td>
</tr>
<tr>
<td>Glenn</td>
<td>Quagmire</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<style type="text/css">
caption
caption-side:bottom
</style>
</head>
<body>
<table border="1">
<caption>This is a caption</caption>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Griffin</td>
</tr>
</table>
</body>
</html>
Dimension
<html>
<head>
<style type="text/css">
img.normal
height: auto
img.big
height: 160px
img.small
height: 30px
}
</style>
</head>
<body>
<br />
<br />
</body>
</html>
<html>
<head>
<style type="text/css">
img
width: 200px
</style>
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
max-height: 10px
</style>
</head>
<body>
</body>
</html>
Set the maximum width of an element using a pixel value
<html>
<head>
<style type="text/css">
max-width: 600px
</style>
</head>
<body>
</body>
</html>
Classification
How to display an element as an inline element
<html>
<head>
<style type="text/css">
p {display: inline}
</style>
</head>
<body>
</body>
</html>
How to display an element as a block element
<html>
<head>
<style type="text/css">
span
display: block
}
</style>
</head>
<body>
</body>
</html>
A simple use of the float property
<html>
<head>
<style type="text/css">
img
float:right
</style>
</head>
<body>
<p>In the paragraph below, we have added an image with style <b>float:right</b>. The result is
that the image will float to the right in the paragraph.</p>
<p>
</p>
</body>
</html>
<html>
<head>
<style type="text/css">
span
float:left;
width:0.7em;
font-size:400%;
font-family:algerian,courier;
line-height:80%;
</style>
</head>
<body>
<p>
</p>
<p>
In the paragraph above, the first letter of the text is embedded in a span element.
The span element has a width that is 0.7 times the size of the current font.
The font-size of the span element is 400% (quite large) and the line-height is 80%.
</p>
</body>
</html>
Cursor properties:
<html>
<body>
<p>Move the mouse over the words to see the cursor change:</p>
<span style="cursor:auto">
Auto</span><br />
<span style="cursor:crosshair">
Crosshair</span><br />
<span style="cursor:default">
Default</span><br />
<span style="cursor:pointer">
Pointer</span><br />
<span style="cursor:move">
Move</span><br />
<span style="cursor:e-resize">
e-resize</span><br />
<span style="cursor:ne-resize">
ne-resize</span><br />
<span style="cursor:nw-resize">
nw-resize</span><br />
<span style="cursor:n-resize">
n-resize</span><br />
<span style="cursor:se-resize">
se-resize</span><br />
<span style="cursor:sw-resize">
sw-resize</span><br />
<span style="cursor:s-resize">
s-resize</span><br />
<span style="cursor:w-resize">
w-resize</span><br />
<span style="cursor:text">
text</span><br />
<span style="cursor:wait">
wait</span><br />
<span style="cursor:help">
help</span>
</body>
</html>
Clear the sides of an element
<html>
<head>
<style type="text/css">
img
float:left;
clear:both;
</style>
</body>
</html>
Positioning
<html>
<head>
<style type="text/css">
div
{
background-color:#00FFFF;
width:150px;
height:150px;
overflow: scroll
</style>
</head>
<body>
<p>The overflow property decides what to do if the content inside an element exceeds the given
width and height properties.</p>
<div>
You can use the overflow property when you want to have better control of the layout. Try to
change the overflow property to: visible, hidden, auto, or inherit and see what happens. The
default value is visible.
</div>
</body>
</html>
<html>
<head>
<style type="text/css">
div
background-color:#00FFFF;
width:150px;
height:150px;
overflow: hidden
</style>
</head>
<body>
<p>The overflow property decides what to do if the content inside an element exceeds the given
width and height properties.</p>
<div>
You can use the overflow property when you want to have better control of the layout. Try to
change the overflow property to: visible, scroll, auto, or inherit and see what happens. The
default value is visible.
</div>
</body>
</html>
<html>
<head>
<style type="text/css">
img.top {vertical-align:text-top}
img.bottom {vertical-align:text-bottom}
</style>
</head>
<body>
<p>
This is an
</p>
<p>
This is an
</p>
</body>
</html>
<html>
<head>
<style type="text/css">
img.x
position:absolute;
left:0px;
top:0px;
z-index:-1
</style>
</head>
<body>
<h1>This is a Heading</h1>
</body>
</html>
<html>
<head>
<style type="text/css">
img.x
position:absolute;
left:0px;
top:0px;
z-index:1
</style>
</head>
<body>
<h1>This is a Heading</h1>
</body>
</html>
Pseudo-classes
Add different colors to a hyperlink
<html>
<head>
<style type="text/css">
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
<p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in order
to be effective!!</p>
<p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order to be
effective!!</p>
</body>
</html>