A Simple One Column Layout with HTML5
The easiest layout to implement with CSS is a one column layout. This is just a series of boxes stacked one on top of the other. We'll have a Header area, a horizontal navigation menu, an area for the contents of the page, and finally a Footer. The layout we'll design looks like this:
The first thing to do is the HTML. The CSS can then be added on top of this.
Have a look in the templates folder that you download with this course (extra_files/templates). (If you haven't got the extra files yet, the download location is here, under the heading Web Design - New Course : Download the Extra Files needed for this course (You don't need the downloads for the old course.)
Open up the template called template_one_col.txt. You should see the following HTML:
NAV
SECTION
ARTICLE
FOOTER
Let's have a look at our code, though.
Starting at the top, we have a HEADER tag:
Our second HEADER is surrounding a pair of H2 tags. This could be the title of an article that we want people to click on.
After the top HEADER tags we have a pair of NAV tags. These are surrounding an unordered list that we want to use as a navigation bar. Previously, we had DIV tags surrounding our unordered list. Now, it's much clearer what this list is being used for.
The next Semantic tag is SECTION. We have two pairs of these. The first pair are at the top and bottom of the page:
In between the first pair of SECTION tags we have an ARTICLE tag. As the name suggests, these are used for when you want to separate an article of text from the rest of your site. You may well have more than one article, in which case you can use another pair of ARTICLE tags. Like this, for example:
Save your template as a HTML file. Save it in a new folder called layouts. For the file name, typelayout_one_col.html.
When you load the page in a browser, you'll see this:
One last thing to do before we get to the CSS. Add the following ID attributes to your HTML code:
Friday, 10 July 2015
A Simple One Column Layout with HTML5
HEADER
In previous versions of HTML you just used the DIV tags in place of the ones above. The new ones are called Semantic tags. They don't actually do anything by themselves - they are just there to make things clearer for you (and perhaps search engines). If you use DIV tags for everything, then page code can get very messy and confusing.
<HEADER>
<H1>Top Header</H1>
</HEADER>
The HEADER tag is not just at the top of the page. If you look further down the page you can see that we have another pair of them:
<HEADER>
<H2>Section Title</H2>
</HEADER>
The HEADER tag should be used when you want a nice heading for different sections of your page. Our first HEADER is for some H1 text. Since it's at the very top of our page, however, we could replace the H1 tags with, say, an image to use as a site banner.
0 comments:
Post a Comment