First we will begin with the HTML, or structure, of our three column layout.
Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
- <head>
- <title></title>
- <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
- <link rel="stylesheet" href="style.css" />
- </head>
- <body>
- <div id="left">
- </div>
- <div id="middle">
- </div>
- <div id="right">
- </div>
- </body>
- </html>
For this exmaple we are actually going to change our HTML a little. Instead of using ids for our divisions we are going to give them all the same class. So our HTML should look like this.
Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
- <head>
- <title></title>
- <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
- <link rel="stylesheet" href="style.css" />
- </head>
- <body>
- <div class="column">
- </div>
- <div class="column">
- </div>
- <div class="column">
- </div>
- </body>
- </html>
Now we will begin with the CSS, or styles, for our three column layout.
Expand|Select|Wrap|Line Numbers
- .column {
- float:left;
- width:200px;
- height:500px;
- border:1px solid #000;
- }
Now we switch back to our first code.
Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
- <head>
- <title></title>
- <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
- <link rel="stylesheet" href="style.css" />
- </head>
- <body>
- <div id="left">
- </div>
- <div id="middle">
- </div>
- <div id="right">
- </div>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- #left {
- float:left;
- width:200px;
- height:500px;
- border:1px solid #000;
- }
- #middle {
- float:left;
- width:200px;
- height:500px;
- border:1px solid #000;
- }
- #right {
- float:left;
- width:200px;
- height:500px;
- border:1px solid #000;
- }