Building a Website Page - Main

What is a Main

Next we come to the <main></main> and I'm sure you can guess by it's name, this is the main part of a webpage where the majority of the page contents are placed. However it does have some rules about it's use and some other useful functionality.

To start with each html page must only have one main element. Inside this we put only the content that is unique and relevant to the subject of that individual page. Which means items that are repeated on multiple pages such as header, footer and primary navigation should not be placed within this element.

an outline drawing showing the header, main and footer areas of a website page

It is also important for accessibility purposes as it helps people who use assisted devices and software to skip over the repetitive content of a page such as headers and navigation and instantly access the pages main content.

Headshot image of Cupcake Tom my website customer

Tom's Website

So far with Tom's website we've established the header section which contains the logo, primary navigation and some contact details (Step 3. Webpage ‐ Header). Now I'm going to put together the main contents of his index (landing) page which will be a mixture of photo's, written text and SVG's.

Because this is a shop website the main emphasis will of course be on the bakery's products. So the easiest way to attract the users attention and relay the message about Tom's fab shop and its quality products is with photographs, because who couldn't resist a picture of a Rainbow Unicorn Cupcake, right!

But we need to make sure there's a good balance of other content too. Otherwise the website will just be a photo gallery which looks okay but not greatly informative. The images also need to be properly sized, saved and optimised to help keep the file sizes as small as possible. If we don't the webpages load speed and performance will be effected.

Defined Webpage Sections

Before we get started there are some element tags that I have used a lot in Toms website that I haven't mention or covered in much detail on the Step 1. The basics page. These are the div <div> and heading <h1> tags.

If you take a look at the front page of Toms website cupcakecatbakery.uk you can clearly see that it is visually split into sections that span across the page. We achieve this by adding a background colour or image to some of the div's and also title headings in larger, bolder text. Both of which help to highlight and define the different subject areas quickly to users.

So lets learn the

Div's

If you take a look at my html you'll notice lots of


<div></div>

tags these are generic containers that don't effect the page content or layout unless styled by CSS. We do this by adding a class to the opening <div> like this


<div class="class_name_here">

which we then choose and add a class name to, this can then be selected and styled in the CSS. Making up the class names is up to you but at some point in the future you or others may need to be able read and understand their relevance.

e.g I have made a panel which contains the hero background image, a heading and a tagline. I named it


<div class="hero_panel">

so basically it's the panel for the page hero image. Now hopefully if I come back to this code in a few weeks months or years I'll be able to clearly understand this, unlike if I'd called it 'that_yummy_bit' as there's likely to be many yummy bits on a bakery site so it doesn't really help us to understand it's actual purpose.

Page Headings

Headings are subject titles just like when your writing an school essay or word document. Though in our html we write them between tags like this


<h1>Title Here</h1>

Just like titles in a document they also have a hierarchy of importance with <h1> being the top level and largest in size down to <h6> the smallest and lowest level. Now as you can see the tags don't look much different in the coded page.


<h1>Heading</h1>
<h2>Heading</h2>
<h3>Heading</h3>
<h4>Heading</h4>
<h5>Heading</h5>
<h6>Heading</h6>

But should look something like this on your displayed webpage.

Headings are also used by web browsers and accessibility software to understand the subject matter of a page, plus the relevance and level of importance of the rest of the page contents. This helps browsers when returning the results of a users search request.

Like a book a webpage should have only one <h1> title. All the other heading tags can be used as many time as you wish and wherever you want on a page. The only rule is making sure the headings on a page are in ascending order without missing out a level e.g. h1, h2, h2, h3, h4 would be ok but h1, h2, h2, h4 missing out h3 would not be. Not following these heading guidelines won't actually break your webpage but it is the recommended best practice.

Now I've establish these points we can now take a look at the <main> section of Toms front page in Toms Main Section 1.

Top of Page