Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

186 LESSON 8: Using CSS to Style a Site


As you can see, the three boxes run straight down the page. I’ve added a border to the
first box, but that’s it. Here’s the source code to the page, with the addit ion of a few other
properties that demonstrate how float works:

Input ▼
<!DOCTYPE html>
<html>
<head>
<title>Floated Elements</title>
<style type="text/css" media="screen">
.right {
border: 3px solid black;
padding: 10px;
margin: 10px;
float: right;
width: 33%; }

.bottom { clear: both; }
</style>
</head>
<body>
<p class="right">
The absence of romance in my history will, I fear, detract somewhat
from its interest; but if it be judged useful by those inquirers who
desire an exact knowledge of the past as an aid to the interpretation
of the future, which in the course of human things must resemble if
it does not reflect it, I shall be content.
</p>
<p class="main">
The absence of romance in my history will, I fear, detract somewhat
from its interest; but if it be judged useful by those inquirers who
desire an exact knowledge of the past as an aid to the interpretation
of the future, which in the course of human things must resemble if
it does not reflect it, I shall be content. In fine, I have written
my work, not as an essay w hich is to win the applause of the moment,
but as a possession for all time.
</p>
<p class="bottom">
The absence of romance in my history will, I fear, detract somewhat
from its interest; but if it be judged useful by those inquirers who
desire an exact knowledge of the past as an aid to the interpretation
of the future, which in the course of human things must resemble if
it does not reflect it, I shall be content. In fine, I have written
my work, not as an essay which is to win the applause of the moment,
but as a possession for all time.
</p>
</body>
</html>
Free download pdf