2 Column webpages HTML / CSS code
We will now create a standard 2 column HTML / CSS web page. Simply copy and paste the code in the form below. Save as a .html file then open it in your browser - it will look like this: 2 col layout
Actually, we'll deal with two CSS methods here that generate the same layout consisting of a top header 800px, a left column 150px wide and a main content area 650px wide. Fairly standard layout... but very useful. The first method uses an internal style sheet, the second uses an external style sheet.
Internal Style Sheet Example
The first example generates the layout using an internal CSS style sheet. This code is contained in between the :
<style></style> tags
Here's the code using an internal CSS style sheet.
Copy > Paste into a notepad file > Save as something.html to your desktop > Then "open with IE" or what ver browser you wish...
Ok...that works pretty well...the page opened and seems like a useful layout. But wait...
What if our website will potentially contain 500 pages? Updating would be a nightmare!
The CSS code that is embedded into the HTML file with the Internal Style sheet controls the entire layout of the page using CSS from within the single page. It controls all styles such as: text, font size, font color, column width, header width etc...
Now... say you want to make a change in the font size, you feel it's too small and need to increase it a few pixels. With a display being controled by an internal style sheet you'll need to modify the CSS on all 500 pages; that is... make your changes to your CSS tags within the head section of each and every page. Of course that's absurd!
So what do we do to make editing site-wide changes easier? We us an external style sheet.
External Style Sheet Example
We will now place all the CSS code which controls that presentation of our web pages in ONE file. written like this:
<link href="style-basic.css" rel="stylesheet" type="text/css"/>
This file, style-basic.css, will be referenced from every page of our 500 page website. The advantage of this? If we want to increase our font size now we simply edit ONE .css file. Since we include a reference to our external .css file on in every web page all .css presentation changes are site-wide - global.
Enough chitter chatter...let's do it! All you need to do is copy and paste these files below.
First copy and paste this code below into notepad - name it style-basic.css.
NEXT copy and paste this code below into notepad - name it 2-col.html
Open and view
With your 2 files saved in the same folder you will now open them in a browser. Simply locate the folder on your harddrive - right click on 2-co.html and click open with IE or whicever browser you wish. The file will open as a "web page"
External Style Sheet Is The Way To Go
It should be quite obvious that an external style sheet makes site wide changes a breeze. I would urge anyone interested in web design to have a thorough working knowledge of CSS and external style sheets. New designers are expected to know CSS. The positive impact it has on site layout, site design as well as SEO is tremendous.
If you are interested in learning CSS in a structured way, there are many online resources to get you up to speed on this somewhat confusing technology - Eric Meyer comes to mind, but there are many other great teachers and methods instantly available online.
Review the web building process: build web site free
Was this helpful? Leave a comment...
Please leave your comment...name or email is not required. If you leave your email we WILL respect your privacy and not spam you. We may update you occasionally with value added info related to web building, web design, CSS, HTML. Thanks!