Site Sponsors

Archive for the ‘Layouts’ Category

IE6 Issue fixed for 3 column layout seo (search engine optimisation)

Thursday, October 9th, 2008

You may remember in my previous post that I had an issue with IE6 for the 3 column layout for seo (search engine optimisation). Well you will be glad to hear that I have sorted it, the latest CSS can be found below, just copy this over your existing CSS from the previous post and there you go, all done.

CSS code

#header, #footer {
width:770px;
margin:0px auto 0px auto;
height:50px;
background-color:#dedede;
}

#navigavtion, #rightSide {
width:150px;
}

#navigavtion {
float:left;
background-color:blue;
padding:0px 0px 1000px 0px;
margin:0px 0px -1000px -620px;
margin-right:150px;
}

#centre {
width:470px;
float:left;
background-color:green;
padding-left:150px;
}

#rightSide {
background-color:red;
float:right;
padding:0 0 1000px 0;
margin:0 0 -1000px 0;
}

#container {
width:770px;
margin:0px auto 0px auto;
overflow:hidden;
}

#footer {
clear:both;
}

3 column layout seo (search engine optimisation)

Thursday, October 2nd, 2008

The example below is for creating a 3 column layout which keeps SEO in mind as the first thing we want the bots to see is our content and not our navigation.

HTML Example code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>3 Column Fixed Width layout</title>
    <link type="text/css" rel="stylesheet" href="style.css" media="screen" />
</head>
<body>
    <div id="header">HEADER</div>
    <div id="container">
		<div id="centre">
			<p>
				Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
			</p>
			<p>
				Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
			</p>
			<p>
				Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
			</p>
			<p>
				Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
			</p>

        </div>
        <div id="navigavtion">
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </div>
        <div id="rightSide">
				Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
			</div>

    </div>
    <div id="footer">FOOTER</div>
</body>
</html>

The CSS code below does all the positioning of the columns for us so it looks like the typical 3 column layout

CSS example code

#header, #footer {
width:770px;
margin:0px auto 0px auto;
height:50px;
background-color:#dedede;
}

#navigavtion, #rightSide {
width:150px;
}

#navigavtion {
float:left;
background-color:blue;
padding:0px 0px 1000px 0px;
margin:0px 0px -1000px -620px;
}

#centre {
width:470px;
float:left;
background-color:green;
margin-left:150px;
}

#rightSide {
background-color:red;
float:right;
padding:0 0 1000px 0;
margin:0 0 -1000px 0;
}

#container {
width:770px;
margin:0px auto 0px auto;
overflow:hidden;
}

#footer {
clear:both;
}

This works in all browsers on the PC apart from the usual suspect IE6 (typical!!). I will look into this issue tomorrow as I have just got in and written this tutorial within 15 minutes and I will also explain what some of the more important parts of the CSS are doing.

2 column layout using CSS with SEO in mind (fixed width)

Sunday, April 27th, 2008

Have you ever wanted a layout with 2 equal column centred in the page without the use of tables by just using CSS? eg:

Well the following tutorial will help you achieve this and is compatible with IE 6/7, FF, Opera, Netscape and Safari (PC)

OK, what we will start off with is a basic XHTML transitional web page with the infamous “Lorem ipsum” as content. You will notice the following <div> tags in the page:

  • header - this section is the header of the page, where the contents are usually a logo, sometimes a quick search and contact details
  • container - the container plays an important role in this page, it is what helps us centre the 3 columns. The following columns are all contained in between the containers opening and closing <div> :
    • navigation - were all the links for the site will be allocated
    • content - were the main content of the site is to be placed
  • footer - this is the section located at the bottom of the page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>3 Column Fixed Width layout</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link type="text/css" rel="stylesheet" href="style.css" media="screen" />
</head>
<body>
    <div id="header">HEADER</div>
    <div id="container">
        <div id="content">
        <p>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </p>
        </div>
        <div id="navigation">
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </div>
    </div>
    <div id="footer">FOOTER</div>
</body>
</html>

You are probably asking “why have I placed the content above the navigation section in the code?”. Well the answer is to do with SEO, as search engine spiders through your site you will want the most important content to appear at the top of your (X)HTML pages so it is read as the highest prority. More information about SEO and page layouts.

Now for the CSS. The CSS will position all the columns, header and footer into the centre of the page. You will notice that there is no body tag called in the CSS, reason being there is no need for the positioning of these elements.

#header, #footer {
width:770px;
margin:0px auto 0px auto;
height:50px;
background-color:#dedede;
}

#navigation {
width:150px;
}

#navigation {
float:left;
background-color:blue;
padding:0px 0px 1000px 0px;
margin:0px 0px -1000px 0px;
}

#container {
width:770px;
margin:0px auto 0px auto;
overflow:hidden;
}

#content {
width:620px;
float:right;
background-color:green;
}

#footer {
clear:both;
}

Breaking down the important parts

Because we dont have the XHTML in the logical order of how we want to view it on the web so we need to re-position the navigation and the content sections using the CSS float property

With the navigation section, we need it on the left so we add float:left; to the css this now re-positions the navigation to the left.

example

#navigation {
float:left;
...
}

With the content section, we need it on the right so we add float:right; to the css this now re-positions the content to the right.

example

#content {
float:right;
...
}

So now we have the main content read by the search engine spiders first as this is our highest priority and on the right hand side of our website. COOL BEANS!!!

This has been tested in the following browsers:

IE 5.x (only problem is the centring of the entire site but the floats are working fine)
IE 6/7
Firefox 1.5/2+
Opera
Netscape
Safari (PC)

The above code has also going through the WSC CSS & HTML validator and passed. :)

Basic horizontal CSS navigation menu

Friday, March 7th, 2008

In this tutorial we are going to create is a basic horizontal navigation using CSS just like the one in the HTMLSource header.

The tutorial will be split into two parts:

  1. The XHTML side
  2. The CSS side

We will start off with the basic XHTML and then get onto the more complex CSS after which will turn our list into a valid inline navaigation.

Right, lets first build our list of links:

<div id="navigation" >
     <ul>
          <li> <a href="http:www.htmlsource.co.uk">Link 1 </a > </li>
          <li> <a href="http:www.htmlsource.co.uk">Link 2 </a > </li>
          <li> <a href="http:www.htmlsource.co.uk">Link 3 </a > </li>
          <li> <a href="http:www.htmlsource.co.uk">Link 4 </a > </li>
          <li> <a href="http:www.htmlsource.co.uk">Link 5 </a > </li>
     </ul>
</div>

You should end up with something resembling this:

  • Link 1
  • Link 2
  • Link 3
  • Link 4
  • Link 5

you may have dots, squares or even images at the begin of each list item, this is dependent on your CSS but we are going to get rid of these, so dont worry about this.

Thats the easy bit done with (told ya that was going to be easy). Now on to the CSS.

Firstly we will remove the discs/squares/images from the front of each UL list item

#navigation ul {
list-style-type:none;
}

Then we make the list appear in one horizontal line by adding the following to the style sheet

#navigation li {
float:left;
padding:0px 10px;
}

The float:left property is added to the list items, this makes each individual list item float next to each other make the list horizontal.

The padding is just a property which I have added to just split the list up so it makes it easier to read, this you can obviously change to your own preference.

This is a working example of a Basic CSS navigation menu

using CSS and blockquote

Monday, February 11th, 2008

The tutorial below will show you how to add speach marks to a quote without the use of images and just the use of pure CSS.

First we start off with the HTML for setting the blockquote in the page. (more information about the use and implementation of blockquote can be found here blockquote)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>CSS Blockquote</title>
    <link type="text/css" rel="stylesheet" href="style.css" media="screen" />
</head><body>
     <blockquote>
          <p>
                 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris et dolor. Morbi imperdiet. Quisque blandit convallis ligula. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque ut augue. Proin rhoncus, diam vitae tincidunt fringilla, magna mi nonummy felis, sed mattis risus elit et mauris. Suspendisse lobortis.
          </p>
     </blockquote>
</body>
</html>

Now for the CSS.

The following CSS will format the blockquote eg. border, width, position and background colour

blockquote {
border : 2px solid #000;
width: 400px;
margin: 0px auto;
padding: 10px;
background-color: #EEF5FA;
}

Now its time to add the quotes into the blockquote using the CSS

/* This is the property before the quote starts*/
blockquote:before {
content: open-quote;
height:0px;}

/* This is the property for when the quote ends*/
blockquote:after {
content: close-quote;
height:50px;
margin:-50px 0px 0px 350px;}

note that you must have the content property on both the before and after otherwise this will not work.

Lets give the quotes soome styling as to not feel out of place with the rest of the content.

blockquote:before, blockquote:after {
color: #85B8E3;
display: block;
font-size: 5em;
width: 50px;
}

OK we are nearly finished. This is what we should have so far in the way of the blockquote appearance.

Blockquote

You will see from the above screen shot that the text/content currently overlaps the quotes, this can easily be solved by adding padding to the <p> within the CSS like so:

blockquote p {
padding-left:50px;
padding-right:50px;
}

And now it should look something like this:
finished blockquote

A web example can be seen here Blockquote CSS Example.

Please note that this pure CSS way doesnt work in all browsers. I have tested this and it works in FireFox, Opera and Netscape. Unfortunately it doesn’t work in any of the IE browsers or Safari PC these browsers would require images but these can be again done in CSS with the use of images.

I will write another tutorial with the use of images within the coming week.

3 equal columns with a fixed width layout using CSS

Thursday, January 24th, 2008

Have you ever wanted a layout with 3 equal columns centred in the page without the use of tables and just using CSS? eg:

3 equal columns with a fixed width layout using CSS

Well the following tutorial will help you achieve this and is compatible with IE 6/7, FF, Opera, Netscape and Safari (PC)

OK, what we will start off with is a basic XHTML transitional web page with the infamous “Lorem ipsum” as content. You will notice the following <div> tags in the page:

  • header - this section is the header of the page, where the contents are usually a logo, sometimes a quick search and contact details
  • container - the container plays an important role in this page, it is what helps us centre the 3 columns. The following columns are all contained in between the containers opening and closing <div> :
    • navigation - were all the links for the site will be allocated
    • centre - were the main content of the site is to be placed
    • rightSide - this column can be used for adverts, rss feeds etc
  • footer - this is the section located at the bottom of the page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>3 Column Fixed Width layout</title>
    <link type="text/css" rel="stylesheet" href="style.css" media="screen" />
</head>
<body>
    <div id="header">HEADER</div>
    <div id="container">
        <div id="navigation">
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </div>
        <div id="centre">
        <p>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </p>
        <p>
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </p>
        </div>
        <div id="rightSide">
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed molestie mauris id wisi. Morbi nisl urna, sollicitudin vitae, mattis non, sagittis eu, mauris. Nulla tellus. In faucibus mi id lorem. Quisque quis tortor et odio scelerisque consequat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae& Proin
        </div>
    </div>
    <div id="footer">FOOTER</div>
</body>
</html>

Now for the CSS. The CSS will position all the columns, header and footer into the centre of the page. You will notice that there is no body tag called in the CSS, reason being there is no need for the positioning of these elements.

#header, #footer {
width:770px;
margin:0px auto 0px auto;
height:50px;
background-color:#dedede;
}

#navigation, #rightSide {
width:150px;
}

#navigation {
float:left;
background-color:blue;
padding:0px 0px 1000px 0px;
margin:0px 0px -1000px 0px;
}

#rightSide {
float:right;
background-color:red;
padding:0px 0px 1000px 0px;
margin:0px 0px -1000px 0px;
}

#container {
width:770px;
margin:0px auto 0px auto;
overflow:hidden;
}

#centre {
width:470px;
float:left;
background-color:green;
}

#footer {
clear:both;
}

Right, you maybe looking at the CSS and thinking WTF! So I am going to try and explain what the properties do (things like width, height and colour I am going to leave as these are pretty self explanatory).

margin:0px auto 0px auto;

What the above CSS does, is it basically helps centre the section thats calling it into the middle of the page. This only works once you have specified a width eg. width:770px; Once the width has been specified then the section appends equal margins either side so therefore centring it.

css property: float

float:left;

float will specify whether a column/element should float, shifting it to the right or left with surrounding content flowing around it. This allows us the have the 3 columns side by side.

css property: clear

clear:both;

This basically clears all floated elements and places the footer element underneath our 3 columns, otherwise the footer would try to surround the floating content causing the footer to come out of position.

padding:0px 0px 1000px 0px;
margin:0px 0px -1000px 0px;

You are probably wondering why I have added 1000 pixels to each of the columns but then removed them again using the margin properties. Simple, this is what helps us expand the columns to be the same length as the centre column (as this is where all the content is generally placed and is longer than both columns). You will notice when these are in place the page will expand to the full 1000px and not to the bottom of the centre column, to get around this just add the overflow property

css property: overflow

overflow:hidden;

The overflow property allows us to manipulate the areas of content that do not fit inside a column or box. In our case it will be the two columns we have assigned the 1000px padding too in the CSS and will shorten them back to the longest column (in our case it will be the centre section).