Professional Documents
Culture Documents
Create A Website Learners Guide PDF
Create A Website Learners Guide PDF
Licensed to:
Best Pacific Institute of Ed.
2014 - 2a ATC New Zealand
www.instant.org.nz
i
About this
Learners Guide
Learning Purpose & Outcomes
The purpose of this unit of learning is to be able to create a website using a mark-up language, for
a specific stakeholder.
Once you have successfully completed this unit of learning, you will be able to do the following.
Plan and design a website for a stakeholder.
Create the website to design specifications, using a mark-up language.
Test and evaluate the website.
Create an end-user document to facilitate the use of the website.
Note:
Before you begin work on this unit of learning you should have completed Unit 25656
Create a website using a mark-up language to meet a set brief, or have equivalent
knowledge and skills.
You should already be familiar with how to do the following, as these are only briefly
reviewed in this guide.
Plan a website to meet the specifications of a provided brief.
Create a website using HTML and CSS.
Test and evaluate the website to ensure it is fit for purpose.
Study Notes
Contents
Planning and Designing a Website 2
Responsive Web Design (RWD) 2
Creating a Brief 5
Putting together a plan 7
Creating an End-User Document 9
Glossary 66
Appendix A: TourNz Website concept sketches and mockups 67
LESSON 1:
Learning Objective
When you have completed this lesson you will understand the basic A space has been left
principles of responsive web design. on the right of every
page for you to make
You will also be able to do the following. notes about what you
Formulate a brief for a website. are learning.
Develop a plan for the development of the website which meets
the specifications in the brief.
Create a conceptual design for the website which incorporates
the principles of responsive web design.
Write a simple end-user document.
http://www.pet.co.nz http://www.fundraise.com
http://mashable.com http://thatma.de/
http://www.sony.com/index.shtml http://foodsense.is
Advantages of RWD
The website looks good on any device.
No need to zoom to see content on smaller devices.
The full website (all pages) is available on all devices.
Saves time and money because you design once, display
everywhere.
Improved Search Engine Optimisation (SEO). SEO refers to the
process of ensuring a website comes up as high as possible in
the search results of a search engine (eg Google). Search engines
generally find it easier to crawl, index and organise content from
responsive websites.
Principles of RWD
Keep it simple
Keeping the layout as simple as possible is the first way to ensure a
page works on any device.
There are a number of technical ways in which responsive web design
can be supported. However, a good, clean, simple design is always
a good foundation.
Always use:
o semantic HTML to structure your content
o valid code (HTML and CSS)
o simple, intuitive navigation design.
Create conceptual designs for
the site pages which outline
what the pages will look like in
different outputs (ie different
viewport sizes, etc).
On the right is an example
of concept designs for the
Nemesis Casting website,
showing what the output
would look like on different
devices.
Creating a Brief
TourNZ is a company which arranges a wide range of New Zealand travel and tourism experiences.
Their clients are mainly aged between 17 and 65, but they also cater for other age groups.
They need a website to showcase their services and to promote New Zealand as a tourism
destination.
They would like you to develop the first six pages of the website:
o Home page (landing page).
o One page each showcasing the following aspects of New Zealand as a tourist destination:
ff Adventure
ff Culture
ff Cuisine
ff Scenery
ff Fantasy (eg Hobbiton)
All pages must be linked to each other.
Each page of the website must include media (eg images, sound or video) and enhancements
(eg use of colour, font faces and styles, etc).
TourNZ would like the pages to be dominated by images, rather than text - to visually
showcase what New Zealand has to offer.
TourNZ have provided you with two different versions of their banner logo. Their banner logo
needs to be included on every page of the website.
They have provided you with a number of other images to be used on the website, as well as
some text content for two of the pages (see the Guide Resources folder for all the supplied
images).
TourNZ really like the font called Montserrat which is available from Google fonts (www.
google.com/fonts). They would like you to use this font family somewhere on each web page.
For example, you could use it for headings. You may use any other fonts as appropriate.
The website pages need to display properly on at least the following:
o Apple iPhone 5 and Apple iPad Mini using Safari browser.
o Generic notebook (1280 x 800 viewport) running Internet Explorer 10 or higher, or running
Google Chrome 31 or higher.
TourNZ want the website to be accessible to as many people as possible, including those who
have vision problems and use a screen reader to access the website.
The website needs to be completed within two month from today.
Key milestones
The example below shows how milestones can be linked to the
resources required.
Testing procedures
You can incorporate your plan for testing with the list of milestones and
steps, or you can create a separate testing plan.
The plan for your testing procedures needs to include the following.
What will be tested?
When will it be tested?
How will it be tested? (This could include an indication of any tools
you will use to help you do the testing).
What to test
Testing and evaluation of the website needs to include the following
aspects.
Accessibility. Do all the web pages display and work correctly on
all the specified devices, platforms and browsers. Is it accessible
to the target audience and to as many people as possible -
including those with impairments (eg visual impairments).
Readability (how easy it is to read the pages).
Legibility (can you read all the text on the pages).
Presentation. For example: Is the layout correct? Are any media
(eg images) loading and displaying correctly?
Functionality. Is it doing what it is meant to do? For example, do
all the hyperlinks work?
Validity. Have you used valid markup (eg HTML) and styling (CSS)?
Have all the specifications for the website (given in the brief)
been met?
Conceptual Design
Your conceptual design for the website must clearly indicate what the
final website would look like. It must include a design for all six pages
of the site and could include sketches or mock-ups of:
page layouts (ie the positioning of text, graphics and other
elements on each page)
a sitemap showing the relationship between pages on the website.
LESSON 2:
Learning Objective
When you have completed this lesson you will have revised what you
already know about using valid semantic HTML5 to:
create the structure of a web page
add text, media and other content to the web page
link the pages of a website.
You should already know how to create a basic website using HTML
for structure and CSS for styling. In this lesson, we will revise what
you should already know to create the basic structure (the shell)
for the first two pages of the TourNZ website (which you planned in
Lesson 1).
Before you do this, lets recap some of the key principles of website
development.
Accessibility is key
When creating your website, accessibility needs to be the key
consideration.
Accessibility refers to how easy it is for the web page to be opened,
viewed, navigated and used by as many people as possible. This
includes people:
o using different browsers
o with visual or other impairments.
Some key ways in which to ensure the maximum accessibility of
your site are to:
o separate the structure and presentation of the site
o use semantic HTML to structure the website.
File Management
Websites are built using a number of different files:
Text files - eg HTML files and CSS files
Graphics files - containing images for your web page(s)
Other media files - eg sound, animation/video.
All these files must be saved in the same folder.
If you are creating a site with many different files, you might have
sub-folders within the main website folder for images, audio, etc.
HTML Elements
HTML tags and elements define the structure and content of a web
page so that it can be interpreted by a web browser.
Elements consist of a pair of tags and the content between the tags.
Element
HTML Attributes
All elements can have attributes. Attributes:
give more information about HTML elements
are always specified in the start tag of an element
Consist of two parts - a name and a value. The value is always in
quotation marks (" "). Look at the example below.
Attribute
1 <!DOCTYPE html>
1
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8"/>
5 <title>Something for everyone. | Tour NZ.</title>
3 </head>
6 <body>
6 </body>
2 </html>
Note: Unlike the other elements, the <meta> element does not
have a separate end tag (ie it is a start and end tag in one).
5 Title element <title> and </title>
All web pages must have a title. This is shown in the
browser title bar and in search engine results.
It is important to choose a title which is meaningful and
useful. This helps to make your site accessible to people
with visual impairments who use screen readers to access
the content on a web page.
NOTE:
The <meta> and <title> elements are indented. This
shows that they are inside the <head> element. For this
reason, they are called nested elements.
Below are some other elements that can be used to help structure a web
page. These are not strictly essential, but they do help to ensure that the
page can be easily styled and that it will be accessible for all users.
NOTE: All these elements are nested inside the <body> element.
Element Function
<p> Indicates the start and end of a paragraph.
Usage Note: If you want to start a new paragraph, you can't just press ENTER on your
keyboard. You need to create a paragraph element for each paragraph.
<h1>-<h6> Different heading levels. These are like the headings in a regular document which help
indicate the content of a new section of text. <h1> Indicates a level 1 (top level) heading
and <h2>-<h6> indicate subheadings.
<ol> Ordered list (eg 1, 2, 3).
<ul> Unordered list (eg a bullet list).
<li> Used for each list item in an ordered or unordered list (ie nested in <ol> or <ul>).
<table> Inserts a table in the web page. The following elements are used to build the structure of
the table.
<thead> - Indicates the heading section of the table.
<tr> - Adds a row to the table.
<th> - Creates a cell in the heading row of the table. This is nested inside the <tr> element
(which is nested in the <thead> element).
<td> - Creates a cell in a row in the body of the table. Nested inside the <tr> element.
<header> Header at the top of a page.
<footer> Footer at the bottom of a page.
<nav> Section of navigational links (ie a group of links to other parts within the document or to
other documents).
<section> Section in a document.
<aside> Information related to, but not part of, the main content of the page. For example, it can
be used for quotes, hints, related external links, etc.
<div> div is short for 'division'. This indicates a generic division or section in a web page.
Because div is not semantic (ie meaningful), only use it when there isn't a suitable
semantic option (eg <header>, <footer>, etc), or when you are using the div only for
styling purposes.
<small> Used together with the paragraph element to show the 'small print' for the page (ie legal
information for the site).
Usage Note: © will insert a copyright symbol ().
Media Elements
Element Function
<img/> Image element - Used to embed an image on a page.
Usage Notes:
Like the meta element, the image element does not have a separate start and end tag.
The image tag must include the following attributes:
src=: to indicate the file name (source) of the image. For example src=images/
tournz_logo.jpg indicates the:
ff name of image file to be inserted - tournz_logo.jpg
ff sub-folder in which the file can be found - images
ff images sub-folder is in the main folder for the website.
alt=: alternative text. If an image doesnt load or someone (with a visual impairment)
is using a screen reader, this text is given instead of the image. This is one way to
ensure the website is accessible to as many people as possible.
An example is shown below.
<audio> and Used to embed audio into a page. The <source> element is nested inside the <audio>
<source> element. It gives the browser information about the audio file to be played.
Usage Notes:
The <audio> tag could include the following optional attributes.
autoplay="autoplay" - will make the audio play automatically when the page is
loaded.
loop="loop" - will loop the audio - so it repeats while the page is open.
The <source> tag must include the following attributes.
src=: to indicate the file name (source) of the audio.
type=: to indicate the format of the source file (audio) - eg mpeg or ogg.
An example is shown below.
NOTE: Not all browsers support all file formats. However, most support either mp3 (.mpeg)
or ogg. This is why audio files are usually embedded in BOTH of these formats.
<video> and Used to embed video into a page. As with audio, the <source> element is nested inside
<source> the video tag. It gives information about the video file to be displayed.
Usage Notes:
The <video> tag must have the following attributes.
width= and height=: to give the size of the video.
It could also have the following optional attributes.
"controls" - gives the user some basic controls for the video - eg play, pause,
enlarge video window, etc.
"autoplay" - will make the video automatically play when the page is loaded.
The <source> tag must include the following attributes.
src=: to indicate the file name (source) of the video.
type=: to indicate the format of the source file (video) - eg mp4 or ogg.
An example is shown below.
NOTE: Most modern browsers support mp4 video. However, it is useful to add an
alternative format like ogg for those that cannot play mp4. This is why video files are
usually embedded in BOTH of these formats.
2. Select Run from the menu or use the keyboard shortcut (F5).
3. Click to select the browser Note the keyboard shortcut you could
in which to preview the file. use to launch a file in a particular browser.
4. When you preview your pages, keep in mind that you have not yet applied styling (using
CSS). Therefore, all the styling (layout, formatting of text, etc) of the pages is not going
to look anything like the finished product. At this point, just focus on checking that all
the content is correct and is displaying in the browser. For example, can you see all the
images that should be there. If not, check that your link references in the HTML code are
correct.
LESSON 3:
Learning Objective
When you have completed this lesson you will have revised what you
already know about using valid CSS3 to style web pages.
Once you have created your HTML, CSS is used to specify how that
content will be presented (styled).
In this lesson you will review the CSS basics which you should already
be familiar with. You will also apply some basic styling to the pages
you created in Lesson 2.
There are two basic steps involved in getting the HTML files and the
CSS to work together.
1. Create an external style sheet (CSS) as a separate file.
2. Insert a link to the external style sheet in each web page HTML file
(using the <link> element).
An example (highlighted in yellow) is shown below.
<head>
<meta charset="UTF-8"/>
<meta name="description" content="Find out how TourNZ can help
you create YOUR ultimate New Zealand experience.">
<meta name="author" content="TourNZ">
<title>New Zealand - Something for Every One | TourNZ</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
Usage Notes:
The link element for the external style sheet is nested in the
<head> element.
More than one external style sheet can be linked to an HTML page.
CSS Syntax
h1 {color:blue;}
declaration
The above CSS rule means that any HTML marked up with the <h1>
element will be displayed in blue in a browser.
IMPORTANT!
Dont forget the:
open and closing curly brackets { }
and the semi-colon (;) at the end of EACH declaration.
If you forget these, it will cause chaos in your styling!
There are a number of ways that a CSS selector can choose the
elements (in the HTML) to be styled. These include the following.
Compound selectors
If you want to style an element which is nested inside another
element, you can use compound selectors. For example, imagine that nav a {
you wanted all the link elements <a> inside a <nav> (ie navigation) font-size:12px;
container to have a font-size of 12px. To do this you would use the
compound selector nav a as shown in the example on the right. }
HTML
Deciding which attribute to use -
<section class="centre">
id or class
...
</section> id attribute
Each element can only have one id
attribute.
<section id="intro"> Only one element on a page can have that
id attribute (ie it is unique).
...
</section> class attribute
Each element can have multiple class
attributes.
Multiple elements on a page can have the
CSS same class attribute (ie it is NOT unique).
.centre { For example, on the same page you could have:
The table which follow summarises some of the more common CSS
rules and their usage.
Text shadow
text-shadow: 1px 1px 2px #000000;
Usage Note:
The property given above is a shorthand
property consisting of the following values:
Value 1 (required) = h-shadow (ie the position of
the horizontal shadow)
Value 2 (required) = v-shadow (ie the position of
the vertical shadow)
Value 3 (optional) = blur (distance of the
shadow blur)
Value 4 (optional) = color (ie colour of the shadow)
Styling lists
There are a wide variety of styles available for
styling ordered and unordered lists. Below are
the most common.
Unordered lists
list-style-type: circle; Circle bullet point
list-style-type: disc; Disc bullet point
list-style-type: square; Square bullet point
list-style-type: none; A list without any bullet point
Ordered lists
List-style-type: decimal; 1. Decimal.
List-style-type: lower-alpha; a. Lower alpha.
List-style-type: upper-alpha; A. Upper alpha.
You are going to use what you have already learned about
Try it for CSS to apply some very basic styling to your web pages.
Yourself In the next lesson you will learn how to apply the remaining
styling to your pages.
1. Use what you have reviewed about CSS to style the index page (ie the home page) as
shown below.
Background colour of
the page:#EAE4E4
There should be no bullet points for any of the unordered list Items.
2. The same basic styling will also apply for the adventure page. You do not need to set up
separate styling for the adventure sheet. Just make sure that you have included the link
to the CSS file in both your index and adventure files.
3. Preview your pages to ensure the styling rules you have created have been correctly
applied.
In the next lesson, you will learn some more advanced ways to use
CSS3 to style your web pages. This includes CSS3 that works to
ensure your pages display well on any viewport size.
LESSON 4:
Learning Objective
When you have completed this lesson you will be able to do the
following.
Add colour to web page elements.
Set the viewport width for your pages.
Work with different units of measurement in CSS.
Use Google Fonts.
In the previous lesson you reviewed the basics of how CSS is used to
style a page. In Lesson 4 and 5, we look in greater detail at how CSS
can be used to apply the finishing touches to the styling of your two
web pages.
Before we do this, we are going to look briefly at how Google Chrome's
Developer Tools can be used to help you create CSS on the fly and
to test your web pages on different devices, platforms and browsers.
Most browsers have their own Developer Tools which you can use to
help you create and check your websites.
In most cases, the Developer Tools can be accessed using the F12
shortcut key.
At the time of writing, Google Chrome has the most powerful set of
Developer Tools. Not only do these tools allow you to inspect the
code of existing websites, they also allow you to make changes to
your CSS in Developer Tools and immediately see what the results
will look like. In the sections which follow you will see examples of
how useful this can be.
Furthermore, Google Chrome Developer Tools includes an Emulator.
This allows you to preview what your web pages would look like on
different devices, platforms and browsers. You will find the Emulator
tool particularly useful to test your pages as you develop them.
Let's look at an example.
2. Right-click anywhere on the page. [Optional] Click here to open Developer Tools in
a separate window. This can be useful because
Developer Tools will open at the it allows you to see the page and the Developer
bottom of your browser window. Tools separately - giving more space for both.
On this side you will see the HTML On this side you will see the Styles (CSS) which
for the page. have been applied to the selected HTML element. In the
Click on the little arrow next to example above, the <body> element has been selected,
a container (eg <body>) to see so the CSS shown is for the body element.
elements nested in that container. Notice that both the styling you set (background-color)
Click on an element to see the as well as some additional styling have been applied.
styles (CSS) which has been The 'user agent stylesheet' (highlighted above) refers
applied to that element. In the to default styling which the user agent (ie the Chrome
example above, the <body> Browser) applies to an element. You can override these
element has been selected. by specifying your own styling. For example, you could
change the default margins for the body element by
declaring the margin size yourself (in your CSS file).
These are the viewport Click here to swap Shows the default user agents (UA)
dimensions of the device the dimensions (ie for the device you have chosen.
you have selected (ie to see what it would Follow the instructions below to
the viewport of an Apple look like on an iPhone make changes to the UA or operating
iPhone 5 is 320 pixels 5 held in landscape system (OS) to be emulated.
wide by 568 pixels high). orientation).
There are three main ways in which colours can be specified in CSS.
By colour name.
Hex codes.
RGB codes.
Look at the example below which shows how to specify the colour
blue using each of the above methods.
Usage Note:
There are many more hex code and RGB colours than colour names.
There are only 17 colour names that are guaranteed to validate in
CSS and HTML validators. This is fine if you only want to specify
simple colours (eg black or white), but for more complex colours and
shades you will most likely use Hex or RGB codes.
Picking colours
There are millions of different Hex and RGB codes representing
different colour values. You are not expected to remember all of these,
so how do you know which Hex or RGB code to use?
You could use a colour picker. There are many colour picker tools
available on the Web. Some of these include:
o The W3schools color picker - http://www.w3schools.com/
tags/ref_colorpicker.asp
o ColorPicker.com - http://www.colorpicker.com/
o HTML Color Codes - http://html-color-codes.info/
A great way to pick your colours, without having to navigate away
from your page, is to use the Google Chrome Developer Tools.
Let's look at an example.
On the home page, you are going to change the colour of the text:
"Click on a tab below .... experience."
You want it to look like the colour shown below (ie a deep, dark green).
1. Start by adding a basic colour rule to your CSS (using the colour
name closest to the colour you eventually want). An example is
shown below:
#menu h1{color: green;}
2. Open Developer Tools (F12).
3. Click to
select the
relevant
element.
4. Click on the colour square.
6. When you have found the colour you want, release the mouse
button.
Use what you have learned about styling colour with CSS and
Try it for what you learned in the previous lesson, to apply the following
Yourself 1 additional styling to your adventure page.
For the overlay text (ie the text that will go over the Huka Jet image)
To make sure the browser reports the correct viewport size of the
device on which the web page is being viewed, you need to add a
viewport meta tag in your <head> element (in your html files).
Look at the example below where the viewport meta tag has been
added to the index.html page.
This will set the viewport for the home page (index.html) to be the
same width as that of the device on which it is being displayed
(content="width=device-width"). Setting the initial-scale (ie
zoom) for the page to 1, also helps to ensure your page displays as
intended.
Add a viewport meta tag to your html files. Note: The meta tag
Try it for for your adventure.html page will be identical to that for the
Yourself 2 index.html file (as shown above).
IMPORTANT: In Lesson 1 you learnt about the principle of designing for mobile or 'tiny' first.
In our case we are targetting our smallest device - the Apple iPhone 5. So when you check
your web pages, do so using the Developer Tools Emulator and set the device as Apple
iPhone 5.
#tabs img {
border-radius: 2.5vw;
}
This will produce an image that looks like that shown on the right
above, regardless of the size of the viewport.
However, if you were to set the border-radius value to a 'fixed' unit
such as 6.4px, the results would look like this:
Border-radius of 6.4px in a 320px wide viewport Border-radius of 6.4px in a 1920px wide viewport
Home page
Adventure page
In the next lesson we will look at some more examples of how CSS
measurements can be used when positioning elements on a web
page.
Google Fonts
Google fonts provides a huge number of free, open-source fonts for
the web. We are going to use one of the Google Fonts for some of the
text on our web pages. To use Google Fonts:
1. Go to http://www.google.com/fonts.
2. Find the font you want to use. In this case, we want to use a font
called Montserrat.
Once you have found the font you want to use:
3. Click.
5. Copy and
paste this code
into the <head>
of your html files.
This provides the
link to the font.
Now you need to use the font-family rule in your CSS file to apply
the font face to relevant sections of text.
Let's look at an example of what the CSS would look like - for the
overlay text ("Looking for an adrenaline rush?"). We have marked up
this element with id="ot" in our adventure.html file.
NOTE: You need to add the font-family rule to your existing #ot
rules.
Preview your adventure.html page to check that the font has loaded.
The overlay text should now look like this:
Find the font you want on the site and then click on 'Webfont Kit' to
download all the fonts and information on how to use them. You are
going to use the font called 'Amble' from Font Squirrel in your web
pages. To simplify matters, the font files you will need are provided
in your Guide Resources folder. Save these into a sub-folder called
'fonts' in your website folder.
You will notice that four different formats of the font have
been provided (see screenshot on the right). This is to ensure
the font will display correctly on any modern browsers. The
most widely supported font formats are ttf and woff, so if you
only have access to a ttf or woff version of the font, it should
display correctly in almost all browsers.
Before you can use the font, you first need to 'declare' it in your CSS.
An example is shown below, declaring the Amble-Regular-webfont.
Font Sizing
Much of what you learnt about sizing in the section on "CSS Units
of Measurement" also applies to the sizing of fonts. Using a 'fixed'
unit of measurement (eg pixels) can cause problems when you are
creating a website to be displayed on different devices.
Look at the example below of what would happen if the font size for
the text "Click on a tab ..." was set to 11px.
Sizing on an iPhone 5 (shown above) looks fine. But the font is far too
small when displayed on an iPad mini (see below).
To solve this problem, use relative units (eg vw) to size your fonts.
LESSON 5
Learning Objective
When you have completed this lesson you will be able to use CSS to
position elements and establish the layout for your web pages. This
includes:
creating horizontal lists
using the position property to position 'outside the box model'
using the z-index property to change the stack order of elements
centring elements.
There are a few more changes you need to make to the positioning
and sizing of the navigation list items.
Each button is a different width - based on the text it contains.
You want each button to be the same size.
The buttons need to be evenly distributed across the page - from
the left side to the right side.
There needs to be an equal amount of space between each button.
The text colour should be white.
The first issue that needs to be addressed is to set padding and
margin sizes for the <nav ul> elements. If you don't do this, the
browser may add its own default spacing. For example, have a look
at the <nav ul> element in Google Developer Tools.
2. Scroll down
1. Click. until you get to
the user agent
stylesheet.
Note that the user agent (ie the browser) has added a margin before
and after of 1em and padding at the start of 40px.
If you scroll down to look at the box layout for the element, you will
see that this results in a top and bottom margin of 16px, and left
padding of 40px.
Set your margin and padding for the <nav ul> element to 0. This will
make it much easier to get the calculations right for the navigation list
items.
Add the relevant CSS rules to ensure that your <ul> element
Try it for has margins and padding of 0.
Yourself 1
Next you are going to add some padding to individual list items in the
navigation so that there is some space between the text and the sides
of the button. You are also going to add a left and right margin so that
there is some space between the buttons.
NOTE: To make matters simpler when we need to do calculations,
we are going to use a single unit of measurement for all our <li>
elements in the navigation, namely %.
The final step is to size each 'button' so that they are all the same
size and are evenly spread across the entire page. First you need to
set the container width to 100% (ie so that it stretches from one side
of the page to the other). To do this add the following CSS rule to the
<ul> element of your navigation: width:100;
Now you need to calculate the width for the <li> element.
So far, 17% of the available width (100%) has been used on padding
and margins. That leaves 83% for the buttons (100%-17%).
In other words, each button can take 16.6% of the space (16.6% X 5
buttons = 83%). So set the width for the <li> element as 16.6%.
margin margin margin margin margin margin margin margin margin margin
-left -right -left -right -left -right -left -right -left -right
0.6% 0.6% 0.6% 0.6% 0.6% 0.6% 0.6% 0.6% 0.6%
PADDING PADDING
PADDING PADDING PADDING
0.6%
1.1%
1.1%
1.1%
1.1%
1.1%
1.1%
1.1%
1.1%
1.1%
1.1%
language
Create a website for a stakeholder using a mark-up
47
48
Now you can use what you know about the box model to move up
the navigation list so that the top of the list sits underneath the logo
banner.
To do this, give your navigation container a negative top margin value
of -3vw (ie margin-top: -3vw;).
Your navigation should now look like this:
At the moment the tabs are sitting on top of the logo banner, rather
than behind it. This is because in the 'natural flow', HTML elements
are stacked in the order in which they appear in your html file. In
this case, the element containing the logo banner is given before the
navigation element, so it is lower down in the 'stack'.
In the next section we will look at how the CSS z-index property can
be used to change the normal stack order.
Add the property to your CSS file and then preview your adventure.html
page again. This time the navigation should be correctly positioned, as
shown below.
NOTE: The element with the lowest z-index (ie stack order) will be
behind one with a higher z-index.
1. Use what you have learned about CSS sizing to get the
menu tabs to look like that shown below. To get you
Try it for started, the margin sizes for the different elements have
Yourself 3 been indicated. You need to calculate what the width
should be for each element.
Make the relevant adjustment to the margins for the <tabs ul> container so that there is a
space between the top and bottom tabs and the edge of the <site_nav> container.
NOTE: You will also need to set the padding for the <tabs ul> container to 0, or the UA will
apply default padding to it.
In the next section, you will learn how to use the CSS position property
to position your menu images correctly in relation to the tabs.
The CSS position property gives you another way to position elements.
There are four main position values which are summarised below.
Static
Value: static
Effect on element position: None. This is the default value and will
mean elements are positioned in the normal flow (ie the first element in
the HTML will be first on the page, followed by the second element, etc).
Effect on layout (space for element): None.
Example:
HTML CSS
<div id="container"> #box 1{position:static}
<div id="box 1"> Box 1 </div>
#box 2{position:static}
<div id="box 2"> Box 2 </div>
<div id="box 3"> Box 3 </div> #box 3{position:static}
<div>
RESULT
Parent Container
Box 1
Box 2
Box 3
Relative
Value: relative
Effect on element position: Lays out elements in the normal flow and
then adjusts the elements position based on the property applied:
top adjusts the element relatively from the top of its normal
position
bottom adjusts relative from the bottom of its normal position
left adjusts relative from left of normal position
right- adjusts relative from right of normal position
z-index changes stack order
Effect on layout (space for element): None. A gap is left for where
the element would have been if the position property had not been
applied.
Note: If you use the position: relative; value and dont specify a top,
bottom, left, right or z-index value, the element will be positioned as
if static (ie as per the normal flow).
Example:
HTML - as for static
CSS RESULT
#box 2{
position:relative; Box 1
right: 10px;}
#box 3{position: static}
Box 2
Box 3
Absolute
Value: absolute
Effect on element position: Positions the element relative to its
closest parent element that is also positioned. For example, if the
Parent Container is positioned as relative, then it will be the closest
parent element in the example shown below. Otherwise, the boxes (in
the example) will be positioned relative to the <html> element.
Effect on layout (space for element): No space is left for the element.
The element is taken out of the normal flow of the document.
Examples:
HTML - as for static
CSS RESULT
#box 2{ Box 1
position: absolute;
right: 10px;}
Box 3 Box 2
#box 3{position: static}
Fixed
Value: fixed
Effect on element position: Similar to absolute, but the element is
always positioned relative to the viewport. This can create a floating
element that stays in the same position, even if you scroll the page.
Effect on layout (space for element): As for absolute.
Relative positioning
You are going to position the main image on the page (marked
with id="image" in the html file) so that it is adjusted 0.7rem from
the top of its normal position (ie 0.7rem down from where it would
normally sit).
You also want to set the maximum width of the image to be 90%
of its parent container.
To do this, add the following to your css file and then preview the
page to see how the image has been positioned.
#image {
position: relative;
top: 0.7rem;
max-width: 90%;
}
#intro{
position: relative;
top: 10px;
}
Absolute positioning
You want the overlay text to be over the image and sitting flush
with the right edge of the viewport. For this reason you are going to
need to remove it from the normal document flow using absolute
positioning.
To do this, you will first need to add position: relative; to
your body element - so that the #ot element can be absolutely
positioned relative to the body element.
Add the following to your css file and then preview the page to
see how the image has been positioned.
NOTE: Add it to your existing #ot properties.
#ot {
position: absolute;
bottom: 45%;
right: -2vw;
}
HINTS
You will need to do the following.
1. Use absolute positioning to position the images as shown (overlapping the tabs).
Remember: In order for absolute positioning to 'work' you have to set a position for the
parent container.
2. Do an initial estimation of the positioning values you will need. Then use the Google
Chrome Developer tools to help you fine-tune the positioning. You can change the
values in the Developer and see what effect it would have on the elements.
Centring an Element
#myButton {
width: 32%;
position: relative;
margin-left: -16%;
left: 50%;
}
If you do not specify dimensions (at least a width) for your images,
they will maintain their original size. This is why the banner logo is far
too big for the iPhone 5 viewport. This is because the banner logo's
original size is 960px wide (much wider than the iPhone viewport).
To find out what the original dimensions are of an image, follow the
instructions on the next page.
1. Right-click on the
image and select
'Properties' from
the shortcut menu.
2. Scroll down.
To get the image to fit the size of its container, all you need to do is
set its width as 100%.
1. 'Find out more' button: Add some space between the button and the text above it.
2. Footer:
Right align the footer text.
Make the footer font size a bit smaller than it currently is.
3. Overlay text: Depending on the sizing you have used for your footer, you might need to
adjust the position of the overlay text.
Your completed pages (for display on iPhone 5) should now look like those shown in
Appendix A.
In the next lesson, we will look at how to ensure the pages display
properly on devices with larger viewports.
LESSON 6:
Learning Objective
When you have completed this lesson you will be able to apply the
following to create responsive web pages.
Different style sheets for different viewport sizes.
Embed different images dependent on viewport size.
You will also learn how to use validation tools as part of the process
of evaluating your website.
Congratulations! You have created the first two pages of the TourNZ
website for display on an iPhone 5.
But what does the website look like when it is viewed on an iPad or
notebook? Use the Google Chrome Developer Tools Emulator to find
out for yourself. You will notice that things don't fit as nicely on the
screen when viewed on devices with bigger viewports. The font size
is too big, and on the notebook, the banner logo looks far too big.
In this lesson we will look at how to address these issues to make sure
that your web pages look good on any device. We have already done
a lot to set up our pages so that they will 'respond' well when viewed
on different viewports. This includes using units of measurement such
as rem, vw and %. Now we will look at two other ways in which to
create responsive pages.
Applying different stylesheets for different viewport sizes.
Embedding different images for different viewport sizes.
You can change your html files so that different stylesheets will be
loaded depending on the viewport size or media type (eg print,
screen, braille, etc).
Look at the example below. The highlighted line has been added to
the index.html document.
<head>
<meta charset="UTF-8"/>
<meta name="description" content="New Zealand has something for
everyone! Find out how TourNZ can help you experience YOUR New Zealand
dream.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="TourNZ">
<title>New Zealand - Something for Every One | TourNZ</title>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="stylesheet" href="large.css" type="text/css" media="(min-
width:601px)">
<link href='http://fonts.googleapis.com/css?family=Montserrat'
rel='stylesheet' type='text/css'>
</head>
The next step is to create the large.css file and add the relevant
styling rules to it. REMEMBER: You don't need to repeat all the rules
- only what needs to change from the 'default' style (ie style.css).
Let's look at an example.
You want the home page to look like that shown below when viewed
on a larger viewport such as an iPad mini.
The key changes are that the font sizes have been changed (made
smaller) and the menu has been changed to a horizontal list.
Let's make one of these changes together.
1. Create a css file called large.css.
2. Add the relevant link (including the media attribute) to your HTML files.
3. Add the following to the css file. This will change the menu from a
vertical list to a horizontal list (and remove unnecessary margin space).
#tabs ul {
display: inline-flex;
margin: 0;
}
As you can see, there are still some sizing and layout issues which
need to be addressed on the page.
Adjust the
maximum width of
the image to 60%. Allow the text to
sit to the right of
the image (ie it is
wrapping around
the image).
#image {
max-width: 60%;
float: left;
margin-right: 3vw;
}
By adding the highlighted attributes (sizes and srcset) you can do the
following.
sizes="80vw" sets the proportion of the image to always fill 80%
of the viewport (width).
srcset information supplies two different images - one with a
width of 960px and one with a width of 1920px. The browser will
use this information to decide on the best image to display based
on the viewport width and the device's display resolution.
2. Click.
Developer forums/blogs
Google Chrome Developer forum - http://www.chromeplugins.org/
google/
Windows Internet Explorer Engineering Team Blog - http://blogs.
msdn.com/b/ie/
Firefox Mozilla Developer Network - https://developer.mozilla.org
Safari Developer Center - https://developer.apple.com/devcenter/
safari/index.action
Glossary
accessibility Ability for anyone to be able to access a web page and its contents,
regardless of whether they have a disability (eg are visually impaired) or
the browser, platform or device they are using.
align(ment) How text is lined up (eg justified, left justified, right justified, centred).
appropriate(ness) Suitable or well-matched to something else.
constraint A limit on something. Examples of constraints could include the amount of
time or money available to complete the website.
content The elements used together to create the presentation. This could include
text content, images, audio, etc.
emulate To imitate the functioning of another device or application. In the context of
website development, emulation means to show what a web page would
look like and how it would function on another device, platform and/or
browser.
functionality What something is able to do.
horizontal(ly) Left to right (width).
radii Plural of 'radius'.
responsive web Designing web pages that display well on different devices with different
design viewport sizes.
requirements Something that is needed or must be done.
RWD Responsive web design.
SEO (Search The process of ensuring a website comes up as high as possible in a
Engine search engine's list of results.
Optimisation)
specifications Requirements and constraints of a document. They are a measurable list
of requirements that need to be fulfilled in order for the document to meet
the brief.
stakeholder Someone who has an interest or stake in what you are creating. In the case
of website creation, the person(s) who asked you to create the website
would be the key stakeholder(s).
target audience The people who will be viewing/accessing the website.
(intended
audience)
user agent (UA) A user agent is software that gets and delivers the content and style from
a web document in a form that the user can understand. Examples include
browsers, screen readers, media players, voice recognition software, etc.
vertical(ly) Up and down (height).
viewport The window or viewing area on the device's screen (ie it is the part of the
screen on which you can see content)
index.html - iPhone 5
adventure.html - iPhone 5
index.html - Notebook
index.html - iPhone 5
adventure.html - iPhone 5
index.html - Notebook
Study Notes
Study Notes
www.instant.org.nz