Advertisement
  1. Code
  2. HTML & CSS

Prototype a Magazine-Style Home Page Template with the Blueprint CSS Framework

Scroll to top
Read Time: 18 min

When Collis launched this site and asked readers for tutorial requests, a common one was for a "magazine themes" how-to for blog platforms. This tutorial focuses on the first part of the process: applying a CSS grid to the design to prototype a home page template.

Demo and Source

You can see a demo of this tutorial by clicking on the "Demo" button, below. For the source, the ZIP file download does not include the Blueprint CSS code.

What We're Building

The focus here is on an web page design example using the Blueprint CSS grid framework, based on my earlier Which CSS Grid Framework article. However, you can apply the same process to any CSS grid framework you prefer. If you don't like using grid frameworks on production sites, you can always replace the CSS code and corresponding HTML classes with your own.

The page design shown below is influenced by numerous WordPress magazine themes, so you might see familiar design elements, though this is not a WP-specific tutorial.

A Typical Graphic Design Process

Let me point out that I am only an "armchair", self-taught designer, and the minimalist nature of my design will reflect my lack of proper training. Hopefully that allows you to focus on the general grid design and coding process, which is based on geometric elements, not on style.

A typical design process for web pages is to start with a sketch on paper, followed by a graphic mockup in Photoshop or Fireworks, etc. Drop in all the design elements, positioned approximately where you want them. Later, in the CSS grid-based design phase, you'll determine exact measurements.)

FilmPundits is a site owned by a friend that I'm building up. The mockup below is one of several "FilmScenic" designs that I've prototyped. The topic of film just lends itself to this example because of the widescreen-style images.

If you want to use a similar design for non-film topics, just adjust the image heights to make them look less widescreen-y. For my design needs, the largest image has to have the most impact. So the composition is positioned slightly off-center, horizontally. This makes the whole page a bit more dynamic and draws the eye to the most important elements.

Let's look at the "guide" lines, below, that form the design grid for the mockup above.

Use your favorite graphics software to turn the guide lines into a "slice" map:

If you are not using a CSS grid, you would either manually code your web page and CSS file at this point, or let your software generate the code for you.

CSS Grid-Based Design Process

Now that we have a graphic design mockup, we need to translate that into HTML and CSS code. To reiterate, using a CSS grid framework speeds up the prototyping process. You can measure your design elements in pixel widths and finetune to suit the CSS grid that you are using. (I'm not getting much into vertical positioning because I tend to control that with image heights and top/bottom margins.)

Here is the process I typically use to apply CSS grids, which treats the graphic design mockup as an aside. You'll have to adjust this to suit your needs.

  1. On a piece of paper, draw a bounding rectangle - landscape or portrait - representing the general shape of your page design.
  2. Partition the bounding rectangle into rough sections: header, footer, main content, sidebar.
  3. Partition the rough sections further, as necessary.
  4. Pick your CSS grid framework, whether pre-built or custom. I'm using Blueprint. You can use this one-page PDF document as a "cheat sheet".
  5. Decide on the maximum page width. I've used the Blueprint default page width of 950 pixels, which is formed of 24 columns of 30 px wide each, and 10 px wide gutters between columns (24x30 - 10 = 950 px).
  6. Mock up your design in raster graphics software (Photoshop, Fireworks, etc.) if you like. I tend to skip this step because. Note that most CSS grid frameworks include a PNG or JPG grid that you can overlay as a guide. I did not use that grid in the graphic design process discussed above.
  7. Decide on minimum widths for your various sections.
    1. I wanted the sidebar to be at least 190 px wide (5 Blueprint columns), but left this until last, to ensure the three small feature blocks at bottom left had priority.
    2. The left side of the "features" block should have a fair bit of white space (>= 30 px, since that's the  width of one column in Blueprint). After twiddling with the higher-priority sections, I settled on 3 columns = 110 px wide.
    3. The three small features blocks need to be the same width. Anything less than 190 px wide would not have the same visual impact. Anything more than 190 px would not leave enough room for the white space to the left. (If I had the time and inclination, I could have created a custom Blueprint framework that would give finer control, or used a larger width page altogether.)
    4. The large feature image's width (590 px = 15 columns) is automatically decided, since it has to span the width of all three smaller feature blocks. Its height/ width ratio is larger than for the smaller feature images, for visual impact and thus to signify that it's "more important" than other page elements. All these images give a widescreen-like appeal, despite different height/width ratios.
    5. In the "Recent Posts" section of the sidebar, the image width is forced to 70 px (2 cols) - instead of my desired 48x48 thumbs - as a result of what horizontal screen real estate is left. (Here's where a CSS grid framework can be a liability: forced sizes.) In the end though, the even the small thumbnails lightly hint at the "widescreen" theme.
    6. Any text blocks that are too wide can easily be fixed by using a smaller font - preferably using a font-family that is still readable at the reduced size.
  8. Determine element heights where possible. Satisfying height preferences is of lesser concern to me, but I minimized the placement of design elements vertically so that the overall page design echoes a "widescreen" feel. At least for this home page template, I did not want the page height to be so large that most readers would have to scroll down. That would ruin the "widescreen" effect.
    1. The menu is only a placeholder and not covered here in code. It spans the entire "content" width of 710 px (18 cols).
    2. The height of the large feature image was decided by the layout. Its proportions should resemble a "wide screen".
    3. The small feature images are a scaled-down version of those I use at another film site. The originals are 470 w x 175 h. Since there's only 190 px wide to work with, scaling an original image makes the resulting height 71 px, which I've trimmed here to 70 px. The resulting proportion still gives a widescreen feel, but echoes the fact that these blocks are not as important as the large feature image.
    4. The height of the text of each small feature section is defined by four vertical sections: movie title, post date, post author and description, as well as several "bottom borders". (In the CSS code later, you'll see that default line height is 115%.)
    5. The height of the items in the Recent Posts block are a minimum 49 px, though they are variable depending on the length of a post's title.
    6. The top of the News section does not quite line up to the top of the small features. There are ways to achieve this, though I've not covered that here.
  9. Determine the final widths of every element, factoring in your grid framework's settings. You can use your paper sketch or graphics mockup as an aid.
  10. Slice up your graphic mockup, if you're using one, and save segments to image files.
  11. Add the necessary Blueprint div tags and class attributes to support your design.
  12. Test and tweak until you have a final design you're happy with.
  13. If you like, strip out the Blueprint framework. This means replacing the explicit framework (HTML, CSS) with an implicit one - which to me sounds like a lot of unnecessary work (but that's just me). At the least, in production, use the "compressed" version of the Blueprint files.
  14. Go live.

If you're a real designer, unlike myself, you'll probably do most of the design mockup in your favorite graphics editing package. I generally prefer to sketch on paper, then mock up on the fly using HTML and CSS (both Blueprint and custom classes), as discussed below.

Grid-Based Coding Process

Now that you have a mockup of your page layout, you can start coding in HTML and CSS. Here is a rough process of the actual coding steps:

  1. Include the necessary Blueprint CSS references and IE conditional code in the head element of your web page.
  2. In the body tag, start with a div whose class attribute is set to "container". This is a Blueprint code to specify a container area for design elements. This sections off the entire page. If you want the grid to be visible, to help you place elements properly, also add the value "showgrid" to the class attribute of this div.
  3. Start refining the blocks into smaller sections using HTML content wrapped in div tags, as well as CSS-controlled rectangles for images. To specify widths, use the Blueprint "span-x" classes. Add in any custom CSS classes that you need. I usually put in redundant custom blocks (with a gray background), then remove them after I have my actual design implemented in code.
  4. You can continue to refine each rough block, or jump to the next step.
  5. Create any necessary logos, icons, or banners that were not already created earlier.
  6. Replace rough blocks with actual design elements. Add the appropriate div tags, any remaining Blueprint class values.

Example HTML and CSS Code

To make the above processes clearer, let's have a look at some actual HTML and CSS code fragments for the film site design example pictured earlier. Keep in mind that I've gone extreme with the non-Blueprint div tags purely for clarity in this tutorial. You will probably want to strip out any excess classes, possibly merge nested div tags.

Note also that I've used some "ugly" non-Blueprint CSS class names for clarity. They are all preceded by "fs-", followed by a functional name, to make it clear what I'm using them for.

I've coded five stages for this tutorial, to illustrate the refinement process in HTML and CSS. Normally, I'd compress stage 1-3.

  1. Blank template with Blueprint "container" class and empty CSS file.
  2. Rough blocking stage 1.
  3. Rough blocking stage 2. Refine rough blocks from stage 1.
  4. Rough blocking stage 3. Final block refinement into necessary sections.
  5. Final web page and CSS.

These steps will be clearer in the sections below.

Step 1: Blank Template Code

To start off with, we want to set up the HTML file:

1
2
<html ... ?>
3
<head ... >
4
<title>FilmScenic Template</title>
5
    
6
  <!-- Framework CSS -->
7
	<link rel="stylesheet" href="blueprint/screen.css" type="text/css" media="screen, projection">
8
	<link rel="stylesheet" href="blueprint/print.css" type="text/css" media="print">
9
	<!--[if IE]>

10
		<link rel="stylesheet" href="blueprint/ie.css" type="text/css" media="screen, projection">

11
	<![endif]-->
12
13
	<link rel="stylesheet" href="style.css" type="text/css" media="screen, projection">
14
15
</head>
16
17
<body>
18
<div class="container showgrid"> <!--  showgrid -->
19
header, content, sidebar, and footer go here
20
</div>
21
22
</body>
23
</html>
  1. Link to the Blueprint "screen" and "print" CSS files. If you use a different directory structure, don't forget to change the URLs accordingly. I've placed the "blueprint" directory below the index.html file, though in production, it probably should go "above" your theme directory.
  2. Link to the custom "style" CSS file, which will contain all the non-Blueprint CSS classes. In this step, that's style.css.
  3. Set up a div with the classes "container" and "showgrid", both part of Blueprint. Using the showgrid class will render the grid we're using, making it easier to see that design elements are being placed properly.

Step 2: Rough Blocking Stage 1

Now roughly block off the entire page (container) into three CSS-controlled sections: fs-mainblock, fs-sidebar, and fs-footer. You can see this in the HTML code below, which fills in some of the div.container element we introduced earlier:

1
2
<div class="container showgrid"> <!--  showgrid -->
3
	<div class="fs-content">
4
		<div class="fs-mainblock span-18 colborder">header, content blocks go here</div>
5
		<div class="fs-sidebar span-5 last">sidebar</div>
6
	</div><!-- end: fs-content -->
7
	<div class="clear"></div>
8
	
9
	<div class="fs-footer span-24">
10
		<p>(c) Copyright 2008-present, This blog</p>
11
	</div>
12
	<br/>
13
	
14
</div>

You'll notice that the divs above use both custom classes and Blueprint classes (span-18, colborder, span-5, last, span-24). The "last" class is very important, otherwise the fs-sidebar section default right margin will not be turned off, and the section will render below the fs-mainblock section instead of beside it. The colborder draws a vertical line between fs-mainblock and fs-sidebar, and takes up a column by itself. This is not reflected in the "span-18" value. In theory, the mainblock actually takes up 19 columns (19+5 = 24 columns, the Blueprint default).

Now we add classes to the custom stylesheet for these three blocks (see below). Note: some of these are temporary, to demonstrate the block rectangles on screen while refining the design. Consult the final style.css file instead of using exactly the rules presented in the CSS code snippets below.

1
2
div.fs-content {
3
	margin-bottom: 20px;
4
}
5
6
div.fs-mainblock {
7
	height: 700px;
8
	background: #ccc;
9
}
10
11
div.fs-sidebar {
12
	height: 700px;
13
	background: #ccc;
14
}
15
16
div.fs-footer {
17
	margin-top: 20px;
18
	padding-top: 5px;
19
	height: 30px;
20
	background: #ccc;
21
	border-top: 1px solid #000;
22
}

The CSS above results in the rough mockup below:

Step 3: Rough Blocking Stage 2

Let's refine the design further by break down the sections. The fs-mainblock div class is divided into fs-header and fs-featured sections. The fs-sidebar is divided into fs-recentposts and fs-newsbox. Here is the refined div.container:

1
2
<div class="container showgrid"> <!--  showgrid -->
3
	<div class="fs-content">
4
		<div class="fs-mainblock span-18 colborder"><!-- s: fs-mainblock -->
5
			<div class="fs-header">Logo + menu</div>
6
			<div class="fs-featured">Featured sections</div>
7
		</div><!-- e: fs-mainblock -->
8
9
		<div class="fs-sidebar span-5 last"><!-- s: fs-sidebar -->
10
			<div class="fs-recentposts">
11
				Recent posts
12
			</div>
13
			<br/>
14
15
			<div class="fs-newsbox"><!-- s: fs-newsbox -->
16
				News
17
			</div><!-- e: fs-newsbox -->
18
		</div><!-- e: fs-sidebar -->
19
20
	</div><!-- end: fs-content -->
21
	<div class="clear"></div>
22
	
23
	<div class="fs-footer">
24
		<p>(c) Copyright 2008-present, This blog</p>
25
	</div>
26
	<br/>
27
	
28
</div>

As before, classes for the new sections are added to the custom stylesheet, style.css. Each section's height is approximated where necessary, and we're once again adding a temporary background to some of the elements, which will be removed in the final style.css file. Here are some additional CSS rules:

1
2
div.fs-header {
3
	//Logo + menu
4
	width: 710px;
5
	height: 110px;
6
	background: #ccc;
7
	margin-bottom: 10px;
8
}
9
div.fs-featured {
10
	// Featured sections
11
	width: 710px;
12
	height: 580px;
13
	background: #ccc;
14
	margin-bottom: 10px;
15
}
16
17
div.fs-sidebar div.fs-recentposts {
18
	height: 370px;
19
	background: #ccc;
20
	margin-bottom: 10px;
21
}
22
div.fs-sidebar div.fs-newsbox {
23
	height: 270px;
24
	background: #ccc;
25
}

This results in the following mockup:

Step 4: Rough Blocking Stage 3

This is the final stage in the mockup process. We add sections for all remaining design elements:

  1. Divide the fs-header div class into fs-logo and fs-horiznav.
  2. Divide fs-featured into fs-txt-featured and fs-features.
  3. Further divide fs-features into fs-bigfeature and fs-smfeatures.
  4. Further divide fs-smfeatures into three blocks, each spanning 5 Blueprint colums. No custom CSS classes are need for the latter.
  5. Divide fs-recentposts into five fs-recentpost sections. (In a later tutorial, these sections will be integrated into WordPress, so only one section will be used in a code loop.)

Here is how our div.container looks now:

1
2
<div class="container"> <!--  showgrid -->
3
	<div class="fs-content">
4
		<div class="fs-mainblock span-18 colborder"><!-- s: fs-mainblock -->
5
			<div class="fs-header"><!-- s: fs-header -->
6
				<div class="fs-logo">Logo</div>
7
				<div class="fs-horiznav">Menu</div>
8
			</div><!-- e: fs-header -->
9
10
			<div class="fs-featured"><!-- s: fs-featured -->
11
				<div class="fs-txt-featured span-3">Featured</div>
12
				<div class="fs-features span-15 last">
13
					<div class="fs-bigfeature">big feature</div>
14
					<div class="fs-smfeatures"><!-- s: fs-smfeatures -->
15
						<div class="span-5">sm feature</div>
16
						<div class="span-5">sm feature</div>
17
						<div class="span-5 last">sm feature</div>
18
					</div><!-- e: fs-smfeatures -->
19
				</div>
20
			</div><!-- e: fs-featured -->
21
			<div class="clear"></div>
22
		</div><!-- e: fs-mainblock -->
23
24
		<div class="fs-sidebar span-5 last"><!-- s: fs-sidebar -->
25
			<div class="fs-recentposts">
26
				Recent posts
27
				<div class="fs-recentpost">recent post</div>
28
				<div class="fs-recentpost">recent post</div>
29
				<div class="fs-recentpost">recent post</div>
30
				<div class="fs-recentpost">recent post</div>
31
				<div class="fs-recentpost">recent post</div>
32
			</div>
33
			<br/>
34
35
			<div class="fs-newsbox"><!-- s: fs-newsbox -->
36
				News
37
			</div><!-- e: fs-newsbox -->
38
		</div><!-- e: fs-sidebar -->
39
40
	</div><!-- end: fs-content -->
41
	<div class="clear"></div>
42
	
43
	<div class="fs-footer">
44
		<p>(c) Copyright 2008-present, This blog</p>
45
	</div>
46
	<br/>
47
	
48
</div>

As you can see, there are a lot of nested divs used. Some of it is merely for clarity in this tutorial. For the rest, on a production site, you can compact some of it or replace the Blueprint classes with your own. Some people prefer to use caching on their sites, when using "magazine" themes with grid frameworks - though that's out of scope for this tutorial.

Each of the new classes gets added to the custom stylesheet, with temporary heights and backgrounds:

1
2
div.fs-logo {
3
	/* Site logo */
4
	height: 90px;
5
	width: 400px;
6
	background: #999;
7
	margin-bottom: 10px;
8
}
9
div.fs-horiznav {
10
	/* Horizontal menu */
11
	height: 25px;
12
	width: 710px;
13
	background: #999;
14
	margin-bottom: 10px;
15
}
16
17
div.fs-featured {
18
	/* Featured sections */
19
	width: 710px;
20
	height: 580px;
21
	background: #ccc;
22
	margin-top: 10px;
23
	margin-bottom: 10px;
24
}
25
div.fs-txt-featured {
26
	/* Featured */
27
	height: 30px;
28
	width: 110px;
29
	background: #999;
30
}
31
div.fs-features {
32
	/* Features */
33
	height: 570px;
34
	width: 590px;
35
	background: #999;
36
}
37
div.fs-bigfeature {
38
	/* Big feature */
39
	height: 260px;
40
	width: 590px;
41
	background: #666;
42
	margin-bottom: 20px;
43
}
44
div.fs-smfeatures div{
45
	/* Small  feature */
46
	height: 280px;
47
	background: #666;
48
	margin-bottom: 10px;
49
}
50
51
div.fs-recentpost {
52
	/* Individual recent post. Height is actually variable, but is a minimum of 49 px */
53
	height: 50px; // Roughly
54
	width: 190px;
55
	background: #999;
56
	margin-bottom: 10px;
57
}

This results in our final mockup stage, which looks fairly close in geometries to our "sliced" graphic design mockup:

We're now ready to produce the final code.

Step 5: Final Template Code

This is the final step in the coding process, where we drop in actual design elements, do cleanup on excess divs and classes, and get rid of any "blocking" elements:

  1. Take all the custom CSS classes and drop the background and height settings - with the exception of fs-horiznav. (Some width settings are necessary. Drop those that are not.)
  2. Now drop in design elements (images, text blocks) in the appropriate places. Use the necessary Blueprint classes. (E.g., I use "div class='clear' " to force a vertical reset after a group of horizontal blocks. Look for this in the sample, and try removing them to see what happens otherwise.)
  3. Add any final div sections and CSS classes, as necessary. E.g., fs-smfeature, fs-posttitle, fs-postdate, fs-postauth, fs-descr, fs-recposts-head, fs-newsbox-head, fs-newsbox-ul.
  4. Remove any custom CSS classes that are no longer necessary. E.g., fs-features, fs-txt-featured.
  5. Remove any custom "constructor" divs that are extraneous, or merge them with existing Blueprint divs in your HTML. I've left them in for clarity.
  6. Note that the CSS file, below, uses "outline" instead of "border" on all of the images. Outlines get rendered over top of an image and thus do not take up additional screen real estate.
  7. The page's default line height is set to 115%.

Now we have our final design, below, which is the same as at the top of this tutorial:

Demo and Download

The final files have none of the gray-blocked elements, and there are additional verbose comments in the style.css file that should help you decipher the purpose of each custom class. The ZIP file includes images cropped from various movie posters, which are the copyright of their respective owners. The Blueprint CSS grid files are not included in the ZIP.

Please note that some minor discrepancies might exist between the source files and the code presented above.

Final Thoughts

Some final comments on the example in this tutorial:

  1. The code presented here is a bit clunky with its extra div tags, but they're used to clearly illustrate a grid-based design process. Specifically, I've stretched out the mockup and coding process to highlight the possible stages. Many of the design elements can be tightened up and their corresponding div classes eliminated in the CSS file.
  2. As you get accustomed to using CSS grid frameworks, it's likely you'll compress the three CSS grid mockup stages discussed above into just one stage, especially if you have a graphic design slice-up to start with.
  3. This is not the only process for grid-based page design. For a much more indepth treatment of grid design, please see Mark Boulton's series, Five Simple Steps to designing grid systems.

This is not a complex example, nor a full theme for a blog platform, but I hope it helps you to understand how to use CSS grids for web page design. While the code here is for a static page, the next step is to integrate it with a blog platform to produce a homepage template.

Advertisement
Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Advertisement
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.