Part 3 – Your Design

Important Considerations

It is important to consider certain things when you are translating your design from paper to screen. We will go through them here.

Width

W3Schools have tracked what monitor resolutions users have used whilst accessing their website for the past 10 years and their results suggest that currently most users use a display of 1024 (width) x 768 (height) pixels or more. This means that most people can display a website with a width of 1000px or less, height for a blog isn’t really relevant, because you expect the posts to scroll down the screen anyway. What is important is to not use a width greater than 1000px because this may mean your blog does not fit on the majority of people’s screens – horizontal scrollbars will put people off your blog and you could easily lose readers because of this.

My blog will use a fixed width of 1000px.

Sidebars

Angry Mob needs a sidebar for links, pages, search boxes and other widgets. It also needs a secondary sidebar for advertising space. I need to consider what width is appropriate for each sidebar – remembering that every pixel I give to either sidebar takes away space for the blogpost to fit in. The Interactive Advertising Bureau [IAB] have set guidelines for standard banner sizes, which makes specifying a width for my advertising space easier. The standard ‘skyscraper’ banner is 120px wide by 600px high, whilst the wide version is 160px x 600px. So my advertising sidebar needs only to be 160px wide.

The other sidebar will contain a variety of links, widgets and useful stuff, so it should be wider than the advertising sidebar, but not leave too narrow a space for my blog posts. Let’s just set it to 240px, leaving 600px spare.

Blogposts

Any remaining horizontal spacing should be left for the blogposts, which should be the focus of any blog, because your content is what people are on your blog for. However, we cannot just allocate the remaining 600px to the blogpost, we first need to consider what spacing should be put between the blog post and the two sidebars, as well as the spacing between the two sidebars. If we put 10px gap between the two sidebars and also a 10px gap between the blogpost and the sidebars then that leaves us with 580px left. However, should we want a coloured background we might also want to put a little bit of space between the advertising sidebar and the background colour. Let’s leave another 10px for this space as well just to be safe. This means we have a width of 570px for our blogposts, which should be plenty.

Remember any of these spaces can be changed later as needed, this is the beauty of CSS design: flexibility. Now we have some basic widths sorted out we can now start to change the layout of our blog.

First steps of creating your basic design

I will go through arranging the basic elements of your blog step-by-step and hopefully you’ll then start to see how things are constructed, and how CSS design combines with PHP instructions to create the layout and look of your blog.

The Header

To look at how the header works go to ‘Editor’ again under the ‘Appearance’ tab and this time select ‘header.php’ from the file list on the right hand side. You’ll then see the instructions that currently control the header, and in fact the instruction that lays out all of the main content:

Locating the 'wrapper' instruction

Click to Enlarge

I have highlighted the div id “wrapper”, it is this instruction that tells all of the content how wide to be, and where to position itself on the screen. What you need to understand is that your WordPress blog consists of several different PHP pages that are brought together by WordPress to create your blog. So this header file is loaded at the top of every one of your WordPress pages, so to customise your header you need only change one file. It is also important to remember that this file also alters the behaviour of any PHP files placed below it – the index.php (your main or front page default layout), any sidebars (sidebar.php) you have and the footer (footer.php). So it is vital to understand the way that ‘divs’ (divisions) work.

This div is labelled ‘wrapper’ and this label describes its function, it literally wraps around all of the content, meaning that anything inside it will abide by the instructions set for that div. The division will end when a closing tag

is entered into the PHP file. If we look at our current header.php file we can see that the two divisions after the wrapper (“header” and “access”) are opened and closed, but their is no closing tag for ‘wrapper’. This means that the wrapper division will continue to control the content that follows.

Let us demonstrate this by inputting some css into our stylesheet. So, select style.css and enter some code, I will explain what each part does so that you’ll learn about what is happening:

#wrapper This is telling the web browser what division you are creating the instructions for. Remember in header.php the instruction is

the # symbol placed directly before wrapper indicates that the division should only be used once within any webpage.

#wrapper {
width: 1000px;
margin-left: auto;
margin-right: auto;
}

The { symbol opens the instructions and the } closes them. I have inputted 3 basic instructions: the width, which is quite straightforward, and two margin instructions. The two margin instructions means that that content will be centred to any screen (no matter how big) because it will always create an automatic margin left and right. This is the standard way of centering divisions.

Your stylesheet should now look like this:

Your first CSS instructions

Click to Enlarge

If you save your changes and refresh your blog you should see that it has now been centered:

Your blog has been centered

Click to Enlarge

What you can see now though, is that we don’t have enough content to really see what things look like, so copy and paste the following into your first post (deleting what was there before it):

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vehicula cursus condimentum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed porttitor orci sed massa suscipit consectetur. Proin fringilla aliquam augue a tincidunt. Sed sodales pulvinar ipsum, nec pharetra arcu porttitor id. Nulla facilisi. Ut sit amet facilisis neque. Vestibulum ante dolor, pulvinar sed condimentum at, auctor a tellus. Etiam fringilla pellentesque felis, vel convallis elit malesuada vel. In mauris dui, euismod in congue a, convallis sit amet dolor. In hac habitasse platea dictumst. Aliquam condimentum, quam vel porttitor pharetra, nulla tortor elementum turpis, nec aliquam justo turpis sit amet nisl. Donec in augue sed est auctor venenatis vel in urna. Pellentesque facilisis tortor placerat felis egestas posuere. Duis ut turpis urna, eget commodo ante. Nunc iaculis malesuada risus at auctor. In posuere porttitor vehicula. Phasellus suscipit tortor id ipsum convallis ac euismod sapien fermentum. Suspendisse vel neque erat.

Donec tortor lectus, porttitor eget viverra ut, tincidunt ac nulla. Cras ipsum ligula, auctor ac varius sed, imperdiet gravida libero. Vivamus nisi diam, vehicula eu tristique eget, dictum ac justo. Donec vulputate posuere dui, eget pulvinar orci consequat id. In dolor purus, ornare ac tempor non, ullamcorper id est. Integer posuere nisi in ligula ullamcorper molestie. Aliquam at nunc in ante luctus ullamcorper vel ut odio. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin lobortis laoreet mauris ut condimentum. Vestibulum rutrum ornare libero sit amet varius. Nulla convallis enim gravida massa eleifend sit amet vulputate enim cursus. Praesent ultricies gravida sodales.

Vivamus ac lacus in sapien rhoncus sodales laoreet at tellus. Ut risus nisi, tincidunt ut adipiscing eu, bibendum in augue. Donec egestas massa sed nulla vehicula luctus. Etiam ultrices auctor velit non vehicula. Suspendisse potenti. Morbi nec nunc enim. Maecenas et diam mi, eget vestibulum metus. Nulla placerat purus id tellus venenatis et faucibus augue dictum. Sed suscipit sem non quam auctor a suscipit turpis pretium. In hac habitasse platea dictumst. Quisque vulputate ante vitae leo sodales mattis.

Aliquam id sapien a diam vestibulum pellentesque nec ut mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vivamus eu velit arcu, ac congue augue. In nec turpis in felis mattis cursus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce feugiat faucibus risus. Integer congue odio nec magna adipiscing fringilla. Donec iaculis, tortor sed luctus ullamcorper, nibh est pulvinar sem, eget pellentesque velit enim sit amet magna. Donec lacinia est non urna feugiat consequat. Quisque elementum nulla in nulla pharetra at suscipit sapien adipiscing. Donec odio risus, tempor at consequat a, sagittis ac lorem.

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed id est sed sapien luctus dictum. Sed imperdiet euismod est nec adipiscing. Nunc porttitor consectetur pulvinar. Quisque lacinia imperdiet arcu eu pharetra. Donec gravida imperdiet turpis, vel luctus eros faucibus a. Sed nisl risus, molestie rhoncus feugiat sed, ullamcorper in nisl. Proin eleifend faucibus risus nec ultricies. Vestibulum sagittis magna vitae mi tristique non tempor massa luctus. In pharetra leo vitae velit mattis ut accumsan mi interdum.

Update your blog and you should now see the real width of your blog:

Your nicely centered blog with some text

Click to Enlarge

Because we currently have no sidebars the content is filling the whole of the 1000px wrapper. Let’s change that by styling the content and adding some sidebars.

First thing you need to do is find out what is controlling how the blog post appears. You can do this by clicking on your Main Index Template (index.php), let’s focus on the instructions right at the start of this file:

Styling your blog post

Click to Enlarge

The first thing you will see is that the page is loading your header.php right away, you’ll soon get used to these PHP instructions, and we might be ammending some of them later. Next up you’ll see a new division:

if you scroll down the index.php file you can find where this is closed:

The closing container tag

Click to Enlarge

As you can see from the two php instructions underneath the closing container tag, the sidebars and footer will be loaded after this container is closed, so we can set the container width and use that to make the blog post, title and meta data etc all the same width without changing the sidebars or footer. Let’s do that now by going back to the stylesheet and adding the following:

#container {
width: 570px;
float: left;
}

Save your changes, refresh your blog and you’ll see the content has narrowed to 570px:

Your content has been resized.

Click to Enlarge

I have added the instruction “float: left” to make sure the content sits as far left as it can, so that we can put the two sidebars into the free space on the right. To do this we first need to check sidebar.php to make sure we know what ids they have:

Styling your sidebars

Click to Enlarge

As you can see, the primary sidebar id is “primary” and the secondary sidebar id is “secondary”, we can therefore specify their widths in our stylesheet as follows:

#primary {
width: 240px;
float: left;
}
#secondary {
width: 160px;
float: left;
}

Once you have saved changes you will need to drag and drop some widgets into these sidebars in order to check that they are working and being displayed where you want them to be. Drag ‘Pages’ widget to your primary sidebar, and the ‘links’ widget to the secondary sidebar. You should then see the following:

Your new sidebars

Click to Enlarge

You will see that your two sidebars are nicely in line to the right of your content. However, because we are using the ‘float’ instruction the footer has moved up to a place where we clearly don’t want it. So let’s style that next. To start with, select footer.php so we can see what is going on:

Your footer.php file

Click to Enlarge

The footer is quite simple, we can see that the div id “footer” will style it. Also, just before the end of the file you can see the closing tag for the “wrapper” division that was opened in header.php. So we can see why all the content has been centered by just one instruction, because everything is ‘wrapped’ by the “wrapper” division. I hope that makes sense, and that you are starting to see how the basic structure is working. So, we can now add an instruction to the footer to make it sit below the content and sidebars properly:

#footer {
clear: both;
float: left;
}

“Clear: both” ensures that nothing floats either side of the footer, is basically ensures that the footer sits below the other divisions. Floating it left makes it appear on the left of the wrapper, this can be changed to right if you prefer. Save the changes to your stylesheet and refresh your blog and your footer should now be below your content:

Your footer should now be in its proper place

Click to Enlarge

Your blog should now look like this:

Your standard blog layout is complete

Click to Enlarge

Congratulations, the basic layout work has been done, we can now look at styling each part to make your blog look unique. This is where the fun and real creativity can start.

Part 3 Checklist

Before proceeding to part 4 you should make sure you have done the following:

  • Selected an appropriate overall width for your blog and added it to the “wrapper” instructions of your stylesheet.
  • Set the width of your content within this wrapper using the “container” instructions in your stylesheet.
  • Set the width of your sidebar or sidebars – it is up to you whether you want one or two – and added this to the relevant instructions in your stylesheet (“primary” and “secondary”).
  • Made sure your footer sits beneath your content using the “clear:both” and “float” instructions.

If you are happy that all of his has been done, then please move onto part 4: Styling your header.

  1. No comments yet.
(will not be published)