You'll build a multipage website that includes everything needed for a valid HTML file.
It'll have the following features:
Command
+ Shift
+ A
on MacOS or Ctrl
+ Shift
+ A
on Windows)Now you're ready to get coding!
Remember what you learned in the semantic tags and layout projects about using body
, header
, nav
, main
, and footer
.
<body>
<header>
...
</header>
<nav>
...
</nav>
<main>
...
</main>
<footer>
...
</footer>
<style>
...
</style>
</body>
On each of your 3 pages, add the semantic elements, and then wrap everything in a body
element.
In general, every page should look like this:
<body>
<header>
...
</header>
<nav>
...
</nav>
<main>
...
</main>
<footer>
...
</footer>
<style>
...
</style>
</body>
Remember what you learned in the layout project about positioning the semantic elements (header
, nav
, main
, and footer
) and using the body
as a container.
On each of your 3 pages, lay out the semantic elements using CSS Grid.
Note: your layout should be the same on every page to make it easier for the user, so copy/paste is your friend!
<style>
body {
display: grid;
grid: " h h h " 3em
" . m . " auto
" f f f " 5em
/ 1fr 5fr 1fr;
}
header { grid-area: h; }
nav { grid-area: n; }
main { grid-area: m; }
footer { grid-area: f; }
</style>
Up until now, we've actually been relying on the browser (such as Chrome or Safari) to assume some stuff about our site. We've let it assume:
To write the code properly, we need to tell the browser specifically all these things.
We'll start with the doctype. It's a statement at the very beginning of the code that says what language it's written in.
On each of your 3 pages, add this line to the top.
<!doctype html>
The body
element contains all the stuff that will appear on the page. However, the extra information about the page needs to go in a different place, where it won't be shown to the user. This is where the head
element comes in.
The head
element sits between the doctype
and the body
, and contains information for the browser about the page, but isn't shown to the user.
On each of your 3 pages, add a head
element between the doctype
and the body
.
<!doctype html>
<head>
<meta charset="UTF-8">
<title> Your website </title>
<link rel="icon" href="favicon.ico">
</head>
<body>
...
Change your title
and favicon
to personalise your web page.
Online validators check that your code has everything that the browser is expecting it to have. Making sure your code passes validation means that it's high quality, and will display the way you want it to in every browser.
Copy and paste all of the code from your index.html into the Markup Validation Service site.
Scroll down and you might notice a few errors listed in red! It's ok if you're intimidated by the technical language they use - we'll work through them together and just look at them one at a time.
The first error is likely mentioning that it saw a head
element before the html
element. Apologies, we deliberately left out the html
element so that we could practice with the validator.
The html element wraps around both the head and the body element. Below is what your HTML code needs to look like on every page.
Try adding an html element to your code and the copy and pasting again into the validator.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title> Your website </title>
<link rel="icon" href="favicon.ico">
</head>
<body>
<header>
...
</header>
<nav>
...
</nav>
<main>
...
</main>
<footer>
...
</footer>
<style>
body {
display: grid;
grid: " h h h " 3rem
" . m . " auto
" f f f " 5rem
/ 1fr 5fr 1fr;
}
header { grid-area: h; }
nav { grid-area: n; }
main { grid-area: m; }
footer { grid-area: f; }
</style>
</body>
</html>
Hopefully, you have no errors this time, but more likely you just have different ones. We'll work through them together, so try talking to the people around you to see if you can figure it out as a team.
Congratulations, the second iteration of your web page is complete.
You've taken the code provided and customised it to create your unique web page.
Along the way, you've learned about these parts of coding.
(➕ means new things in this project)
HTML code
h1
for main headingsh2
for subheadingsp
for paragraphsul
for unordered lists (bullet points)li
for list items inside an unordered liststyle
for CSS stylinga
for linkshref
attribute in a
opening tagsimg
for imagessrc
attribute in img
opening tagsheader
for page headersnav
for navigation menusmain
for the main page contentfooter
for page footersbody
for the whole page the user can seediv
for a containerHTML vocabulary
<
and >
CSS code
background:
to change the background colour of an elementfont-family:
to change what letters look likefont-size:
to change the size of textcolor:
to change the colour of texttext-align:
to move text to the left, center, or righttext-decoration:
to add or remove underlines and line-throughstext-transform:
to change text to all uppercase or lowercasetext-shadow:
to add a shadow to textmargin-
(top
, bottom
, left
, right
):
to add space around the outside of an elementpadding-
(top
, bottom
, left
, right
):
to add space around the inside of an elementwidth:
for the widthheight:
for the heightdisplay:
to change the way this should be shown, e.g. grid
or flex
grid:
to change the way the page layoutgrid-area:
to give an element a letter to use in gridjustify-content:
to change where inside the container the items should be placedgap:
to space the items in a containerflex-direction:
to change the direction items are arranged in a containerflex-wrap:
to continue items on a new line if they don't fit on the pageCSS vocabulary
In your coding career you will often need to look up how to do things. In this section are a couple of websites to help you find information online about how to do what you want to do.
Most frequently, a good Google search will be the best option. Remember to include the keywords "HTML" and the thing you want to do, so that Google will give you the best results (skip past the ads though!).