Tuesday, November 5, 2024

CSS Template Layout – part 1 of 3

Having been asked by several readers, I have decided to create this easy to understand tutorial on creating web pages with CSS. I will not be able to expose to you everything there is about CSS in this tutorial, but I will be able to give you enough to create a nice looking page. After completing this tutorial you should have enough to explore CSS and web page design even further.

>> You may want to review CSS by checking out my beginners article on CSS.
>> You can download the CSS and HTML files we build in this tutorial: CSS files
>> You can check out what the page should look like here: CSS example page

Tags used in this CSS based layout:

Because of the power of CSS, we will be able to reduce the number of HTML tags we use in a page big time, all the while still being able to layout great looking pages using only 6 types (for lack of better words) of HTML tags.

The tags we will use to layout the content:

1. <h.> The Heading tags which range from ‘<h1></h1>‘ to ‘<h6></h6>‘ , are going to be used to mark/tag headings in our pages. So the most important heading will be wrapped in a <h1> tag and the least important in a <h6> tag. An example of a heading for this article:

<h1> CSS Template Layout </h1>

This tells the browsers and the search engines too, that this page is primarily about: ‘CSS Template Layout’

All browsers have a default size (for each <h.> tag) as to how it renders text when placed between these tags. Many of these defaults can be unusable (especially <h1> ) because they come out too big. But never fear CSS is here, and we will use CSS to make the text sizes more to our liking.

2. <p> The Paragraph tag is used to mark parts of the pages as being ‘paragraphs’, simple enough. Paragraph tags are what they call a ‘block element’; that means that it acts like a block where a space is automatically inserted before and after each <p> tag pair. You see it work in the examples coming up.

3. <ul> and <ol> List tags will used to create our menus. The tag <ul> is the ‘un-ordered list tag’ that creates a list with bullets or other images/icons that do not specify or denote an order; hence the term ‘un-ordered’. The other list tag mentioned ( <ol> ) is the ‘ordered list tag’ and it creates a list that, instead of bullets, the list elements are marked with numbers or letters. Code examples to follow.

4. <div> We all know what the <div> tag is about since we all read the previous article, right? We will use div’s to create containers for parts of our page. One div will be used to ‘hold’ our navigational menu and another div to ‘hold’ the main page.

5. <a href> The most important tag in HTML: the ‘link tag’ or the ‘hyperlink tag’. This makes text ‘hyper’ so that when we click on it we can load another page or activate/call some JavaScript (otherwise known as ECMA script).

6. <img> This is the ‘image tag’, allows you to link to images so that they show up in our pages. In HTML images are not embedded into the actual page, instead the image tag ( <img> ) only points to where the image is and the browser will attempt to load that image when a surfer loads your HTML page.

That covers the HTML tags we will use in our layout! No need for table tags, <br> tags and nasty <font> tags.

The basic page template:

Go to the Web Designers Killer Handbook home page and grab the practice HTML page that we will use as the starting template for this tutorial. You can find it under the heading: ‘To create the practice HTML page do the following:’ Follow the instructions there and create your basic HTML page.

Once you have created the template page, create a folder and name it something like: ‘myCSSwebsite’ and then drop the HTML page into it. In that same folder, create a new text document and call it: ‘myCSS.css’. Once created open that file and paste in this template CSS code and then save it:

-==-

Once you have created the template page, create a folder and name it something like: ‘myCSSwebsite’ and then drop the HTML page into it. In that same folder, create a new text document and call it: ‘myCSS.css’. Once created open that file and paste in this template CSS code and then save it:

Don’t let the CSS freak you out, I will explain the important details and you will soon see how easy it really is. One last thing for you to do before I finish this part of the tutorial, we need to add some code to our HTML page.

In between the <body></body> tags you will need to insert this code:

-==-

With this in place we will be able to start styling our page. If you take a look at the HTML page now you may be surprised to see that we already started!

If you haven’t set the page up yet, please do so to make sure you have everything working thus far. Should you have any problems, go to the Forum and post your questions.

» Continue to Part 2

Stefan Mischook has been developing web sites and web applications since 1994. Stefan has spent the last several years working on dozens of web and multimedia projects for small business and large pharmaceutical and banking organizations. Along with contract work, Stefan now runs the popular web sites www.killersites.com and www.how-to-build-websites.com writing concise to the point articles with the aim of teaching people real-world web design skills.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles