HTML CSS Javascript Manual
HTML CSS Javascript Manual
Although the manual will serve as support material for teachers who attend the Web
Application Development Workshop component of our two-year CPD programme, it is
envisaged that its real value will only come into play in the months after the workshops have
been delivered. Beyond these workshops, the manual may be used as a basic reference for
web development, but more importantly, as a teaching resource that might be used to
promote in teachers, a constructivist pedagogic orientation towards the planning and
teaching of web development in the LCCS classroom.
The manual itself is divided into five separate sections and is divided into three separate
hardcopy documents. This is Part A.
Part A
Section 1 – HTML
Section 3 – UX Design
Part B
Section 4 – JavaScript
Part C
Section 5 – Databases
HTML
Introducing HTML 07
• How the web works
• What is HTML?
• My first page
• Web browsers
• HTML tags
• HTML page structure
• HTML versions
• Exercise 1 - first page
• Reflection exercise
Tables 38
• A basic table
• Exercise 5 - Opening hours table
Forms 45
• Text controls
• Option controls
• Checkboxes
• Radio buttons
• Lists
• Buttons
• Labelling controls
• Grouping controls
• Exercise 7 - Forms
Breakout Exercises 54
• Breakout A - Monster mark up
• Breakout B - Mark up a formal letter
HTML Glossary 63
HTML Resources 64
• Clients are the typical web user's internet-connected devices (for example, your
computer connected to your Wi-Fi, or your phone connected to your mobile network)
and web-accessing software available on those devices (usually a web browser like
Firefox or Chrome).
• Servers are computers that store webpages, sites, or apps. When a client device
wants to access a webpage, a copy of the webpage is downloaded from the server
onto the client machine to be displayed in the user's web browser.
The client and server we've described above don't tell the whole story. There are many other
parts involved, and we'll describe them below.
• The internet connection: this allows you to send and receive data on the web. It's
basically like the street between your house and the shop.
• DNS: Domain Name Servers are similar to an address book for websites. When you
type a web address in your browser, the browser looks at the DNS to find the
website's real address before it can retrieve the website. The browser needs to find
out which server the website lives on, so it can send HTTP messages to the right
place (see below). This is like looking up the address of the shop so you can access
it.
• Component files: A website is made up of many different files, which are different
parts of the goods you buy from the shop. These files come in two main types:
o Code files: Websites are built primarily from HTML, CSS, and JavaScript.
o Assets: This is a collective name for all the other items that makes up a
website, such as images, music, video, Word documents, and PDFs.
2. The browser sends an HTTP request message to the server, asking it to send a copy
of the website to the client. This message, and all other data sent between the client
and the server, is sent across your internet connection using TCP/IP.
3. If the server approves the client's request, the server sends the client a "200 OK"
message, which means "Of course you can look at that website! Here it is", and then
starts sending the website's files to the browser as a series of small chunks called
data packets.
4. The browser assembles the small chunks into a complete website and displays it (the
goods arrive at your door!).
DNS explained
Real web addresses aren't the memorable strings you type into your address bar to find your
favourite websites. They are special numbers that look like this: [Link].
This is called an IP address, and it represents a unique location on the web. However, it's
not very easy to remember. That's why Domain Name Servers were invented. These are
special servers that match up a web address you type into your browser (like "[Link]")
to the website's real (IP) address. Websites can be reached directly via their IP addresses.
You can find the IP address of a website by typing its domain into a tool like an IP Checker.
Earlier we used the term "packets" to describe the format in which the data is sent from
server to client. Basically, when data is sent across the web, it is sent as thousands of small
chunks, so that many different web users can download the same website at the same time.
If websites were sent as single big chunks, only one user could download one at a time,
which obviously would make the web very inefficient and not much fun to use.
What is HTML?
HTML is the standard markup language for creating Web pages. It is not a programming
language; it is a markup language used to tell your browser how to structure the pages you
visit. It can be as complicated or as simple as the web developer wishes it to be.
Web Browsers
The purpose of a web browser (Chrome, IE, Firefox, Safari) is to read HTML documents and
display them. The browser does not display the HTML tags, but uses them to determine how
to display the document:
HTML Tags
HTML tags are element names surrounded by angle brackets:
1. The opening tag: This consists of the name of the element (in this case, p),
wrapped in opening and closing angle brackets. This states where the element
begins or starts to take effect.
2. The closing tag: This is the same as the opening tag, except that it includes a
forward slash before the element name. This states where the element ends.
Failing to include a closing tag is a common beginner error and can lead to
strange results.
4. The element: The opening tag plus the closing tag plus the content equals the
element.
• Users looking at a web page tend to scan quickly to find relevant content, often just
reading the headings to begin with (we usually spend a very short time on a web
page). If they can't see anything useful within a few seconds, they'll likely get
frustrated and go somewhere else.
• Search engines indexing your page consider the contents of headings as important
keywords for influencing the page's search rankings. Without headings, your page
will perform poorly in terms of SEO (Search Engine Optimisation).
• Severely visually impaired people often don't read web pages; they listen to them
instead. This is done with software called a screen reader. This software provides
ways to get fast access to given text content. Among the various techniques used,
they provide an outline of the document by reading out the headings, allowing their
• To style content with CSS, or make it do interesting things with JavaScript, you need
to have elements wrapping the relevant content, so CSS/JavaScript can effectively
target it.
The HTML head is the contents of the <head> element - unlike the contents of the <body>
element (which are displayed on the page when loaded in a browser), the head's content is
not displayed on the page. Instead, the head's job is to contain metadata about the
document.
Metadata is data that describes data, and HTML has an "official" way of adding metadata to
a document - the <meta> element. There are a lot of different types of <meta> elements that
can be included in your page's <head>, but we won't try to explain them here.
HTML5
HTML5 is the new web standard. It follows HTML 4 (which came out in 1997) and XHTML.
Since the introduction of HTML4, a lot has happened with the web and something needed to
be done to address all the new technologies and latest multimedia. HTML5 is the result of
cooperation that began in 2006 between the World Wide Web Consortium (W3C) and the
Web Hypertext Application Technology Working Group (WHATWG).
The basic aim of HTML5 is to provide two things (1) to improve the language and (2) to
support the latest multimedia. In order to accomplish this, some ground rules were
established by the W3C and WHATWG. Among them were to reduce the need for external
plug-ins (such as Flash plug-ins), better handling of errors, and more markup elements
(tags) to replace scripting. HTML5 should also be device independent (that is, understood by
computers and the many devices in existence today) while also keeping it easily readable.
Reflection
Reflect on what you have learned about HTML so far.
1.
2.
3.
4.
5.
This paragraph below shows how multiple spaces between words are treated as a single
space. This is known as white space collapsing, and the big spaces between some of the
words will not appear in the browser. It also demonstrates how the browser will treat multiple
carriage returns (new lines) as a single space, too.
Before you start to mark up your text, it is best to understand what HTML does when it
comes across spaces and how browsers treat long sentences and paragraphs of text.
Creating Headings
No matter what sort of document you are creating, most documents have headings in some
form or other.
Reflection
Reflect on what you have learned about formatting text in HTML.
Use the space below to write three different tags for formatting text.
1.
2.
3.
The list items will be marked with bullets (small black circles) by default.
In the following sentence, the words can cause blindness are contained inside the <strong>
element.
Using the default HTML styling of most web browsers, it will indent the right and left margins
both on the display and in printed form, but this may be overridden by Cascading Style
Sheets (CSS).
Reflection
Reflect on what you have learned about fine-tuning your text in HTML.
Use the space below to write three different tags for fine-tuning your text.
The mailto link is written in the same format as a hyperlink except you use mailto: in place of
the http:// and your e-mail address in place of the page address or URL. You must include
the </A> code at the end of the line in order for the mailto link to work. There is NO space
between the mailto: and the e-mail address.
Then, add a link to the bookmark ("Jump to Chapter 4"), from within the same page:
Tables
Ø
Ø
Ø
Ø
Ø
Ø
Ø
Ø
Ø Images
Ø
However, it is common to store images in a sub-folder. You must then include the folder
name in the src attribute:
Roughwork
HTML forms serve the purpose of collecting information, which is later sent back to the
server. For proper operation, it's important that the form provided in HTML is paired with
some server-side code, usually called "processing agent", that will be responsible for
receiving and processing the information as the author sees fit. This processing may consist
of, for example, saving the information received or sending it by e-mail.
A form is basically a container for controls. Each control in a form is thought to collect
information input by users, in ways that go from text lines to file uploads, through options,
dates, passwords and many more. Once users have filled the form with data, they can
submit it back to the server in order to let the processing agent administrate the gathered
information.
The following code shows the basic structure of a form, with its opening and closing tags
wrapping a set of controls.
<form>
[Set of controls]
</form>
But this model says nothing about how the form is going to be processed and where. Such
information can be provided with attributes like: action, which indicates the location of the
processing agent; method which determines the method used to pack form data before it's
sent to the processing agent; and target, which indicates where the processing results will be
displayed. Here we'll talk about the action attribute alone, leaving the other two to be
analysed in the reference of form.
The following form has been declared with the URI of a processing agent in
the action attribute. You can see the processing agent taking over in a new window when
you submit the form.
<form action="../[Link]" target="_blank">
<input type="submit" value="Submit the form">
</form>
With this alone, the control is already visible, but a name is needed if there's an intention to
gather the data entered by the user in this control. The value of the name attribute will
identify, server-side, the user's input in the control. The following example shows a basic
implementation of a text input. Additionally, we're enclosing the control and its label in
a paragraph, as these two can be considered to conform a unit with an idea that separates it
from the rest.
After sending the form's data you can see clearly in the information displayed by the
processing agent, how the data is received server-side. There you can also see that
the name declared for the control is associated to the data entered by the user.
In the following example we're improving the previous form to allow both types of text strings
(single-line and multi-line) to be entered. In the example proposed, each control adapts
better to the type of data it's supposed to collect.
Option Controls
These controls allow users to select one or more options form a list of predefined values.
Option controls can be presented in different styles and with different mechanisms of
interaction with the user, depending mainly on the element utilized. A list of options can be
declared in three ways: with checkboxes, with radio buttons and with lists.
Checkboxes
A checkbox is a particular type of option that can be checked or unchecked upon user
interaction. This allows authors to collect data like preferences, acceptance of terms y
conditions, categories, or any other subject that can be answered with "yes" or "no". One
thing this control has in particular is that, even when it can be declared as part of a thematic
group, each checkbox is independent from all other checkboxes in the form.
Checkboxes are represented by the input element, when it has the value "checkbox" in
the type attribute. Here the value of the name attribute also plays a role, by identifying the
option server-side. In the following example, a few checkboxes have been declared as part
of a thematic group of options. Remember that this aggrupation is only made by theme and
position; the selection of checkboxes continues to be independent.
A couple of things can be noted in the previous example. The first one is the lack of
association between the checkbox and the text that describes it or, in other words, the
impossibility of activating the checkbox by clicking the associated text. This is something that
can be easily remedied converting the text into a label for the control, subject we'll treat later
in this tutorial.
The second one is about how checkbox data is received server-side. If you submit the form,
you'll see that only the selected checkboxes are sent to the processing agent. Their value,
that depends very much on the language used server-side, is irrelevant considering that the
mere presence of the checkbox's data is indicating, alone, its activation state.
Radio Buttons
While checkboxes are independent and can be declared on their own, radio buttons are
options that need to be grouped in order to have a meaning. Only one option can be
selected at a time. This means, among other things, that when you select one option, the
previous selected option gets deselected.
A radio button is also declared with the input element, but with the value "radio" in
the type attribute. Here things get a little different from what happened with checkboxes,
because the value of the name attribute needs to be shared by all the options in the same
group. In other words, this is the mechanism that needs to be used in order to create a group
of radio buttons.
But then, where's the value that tells the processing agent what option in the group has been
selected? The answer to this question is in the value attribute. As the purpose of this
attribute is to identify options in a group, its value should be different for each option.
In the following example a group of radio buttons has been declared to conform a group
where only one option can be selected, something that absolutely makes sense in this
context. For this purpose, all the buttons share the same name and have each a
different value.
Lists
A list of options is a control that can resemble, concerning its mechanics, each of the two
controls previously analysed, depending on the presence of the Boolean attribute multiple.
This attribute changes radically the behaviour of a list, by making possible the selection of
only one single option at a time or many.
The structure of a list is composed, mainly, by two elements: select, that acts as the
container for the options; and option, that represents one of the many options the control
may present.
When the multiple attribute is absent, a list control behaves like a radio button group, where
only one option can be selected at a time. The next example reflects this behaviour, which
fits perfectly with the purpose of the field.
<p>
Gender:
<select name="gender">
<option>Male</option>
<option>Female</option>
</select>
</p>
<p><input type="submit" value="Send data"></p>
</form>
In the previous example, you can see that what's sent to the server is the content of the
selected option. But authors can change this behaviour if they think it's necessary, by
declaring the attribute value for the option. When this attribute is present, its value is sent to
the processing agent instead of the content of the element.
Buttons
A button is a special type of control that's been designed to interact with the user in a
singular way: an action is executed every time the user presses it. There's a wide range of
buttons, each having some peculiarities in relation to its capabilities or behaviour, but here
we'll only analyse the two most widely used in basic forms.
Submit buttons
A submit button has the predefined action of submitting the form when activated. Unless
other mechanisms for form submission are provided, the presence of this button is
necessary if there's an intention to allow users to submit the form.
Submit buttons are inserted with the input element, having the value "submit" in
its type attribute. The value attribute is important in this control, as its value is displayed as a
label inside the button. The following example shows a form with a text input and a submit
button.
Reset buttons
Like submit buttons, reset buttons also have a predefined action. But in this case, the
predefined action consists in the reset of the form fields to their initial values. In other words,
the state of the fields in a form that's been reset is the same as when the page has loaded.
This action removes all changes the user has applied to the values of the controls.
It would be good to note here that all controls may have a predefined value, this is, a value
that's present in the form when the page loads. The way authors have to specify this default
value depends on the control. To know how to specify a default value in a particular control
type, check the reference for the control in this list.
In the following example you'll be able to test the functionality of the reset button.
This form has been declared with a single-line text input, a couple of radio buttons and
a checkbox. All these controls have a default value specified with the
attributes value and checked.
Labelling Controls
Almost any control in a form can be labelled. Labelling controls is a worthwhile operation that
enhances accessibility on many fronts. This association between a piece of text and a
control will solve the problem noted in previous examples of this tutorial, particularly
with radio buttons and checkboxes.
Grouping controls
Sometimes, when a form is large, segmentation might play a role in the improvement of
organisation and ease of use. This is why HTML provides the fieldset element, which is a
container for controls. With this element, authors can make divisions to the form and
organize controls thematically.
A fieldset can also have a title to identify the composition or purpose of the set of controls it
contains. This title can be provided with the legend element, which must be declared as the
first child of the fieldset. The following example shows a small form divided into two thematic
groups.
<form action="../../[Link]" target="_blank">
<fieldset>
<legend>Personal information</legend>
<p><label>Name: <input type="text" name="fullname"></label></p>
<p><label>Address: <input type="text" name="address"></label></p>
</fieldset>
<fieldset>
<legend>Preferences</legend>
<p>
<label><input type="checkbox" name="arts"> Arts</label><br>
<label><input type="checkbox" name="television">
Television</label><br>
<label><input type="checkbox" name="videogames">
Videogames</label><br>
<label><input type="checkbox" name="sports"> Sports</label><br>
</p>
</fieldset>
<input type="submit" value="Send data">
Roughwork
Sourced from
Getting Started
You will redesign a jumbled webpage into something more clear and informative for your
readers! Download all the files from the folder supplied.
If it works, you should have a title on its own line on your webpage because h1 is a
block element.
2. Make a paragraph
Next, let's use the <p> tag to create a paragraph. Paragraphs are block elements, so
if we do this right, the paragraph should be on its own line, so to speak, with space
above and below it.
Now we'll try to put the <img> - or image - on its own line. Images can be treated like
block elements or inline elements depending on whether or not you wrap inline text
around them. Let's try to give the image its own space with one paragraph above it
and one below it. Hit return to put the <img> tag on its own line like this:
If you want to use a different picture, find one online with a search engine
like Creative Commons that will find images you are free to use. Once you have the
URL, or web address, of your new image, replace the src - or source - of the original
image with your new address.
The alt attribute here stands for "alternative text." That text will show up if the image
or link to it is ever broken and it's what the computer reads out loud to people who
use screen-readers to help them access the web if they have difficulty seeing a page.
Always include alt text for your images to improve the accessibility of your webpage!
For our next step, we'll make a list. We'll build the list using the stats shared on the
webpage. To make a list in HTML you can use an ordered list tag - <ol> - with list
items - or <li> - that show up as numbers. You can also use an unordered list tag
- <ul> - to make a list with bullet points instead of numbers. Each list and list item is
its own block element.
• <ul>
• <li>345 equally adorable monsters</li>
Finally, wrap the rest of the text in its own closing paragraph. You can also break up
the text into several paragraphs if you want to chunk the information further.
Check out the <a> which is the tag for a link. You can see that links are inline - they
stay within the line of text that holds the link. You can try to change the href - or
"hypertext reference" - of the link to one of your favourite websites to share with your
fellow learners.
Go back through your paragraphs and add some style using the tags for bold, italics,
and underline. Try to use each tag at least once to highlight parts of the page that
you want to emphasize.
Congratulations on revising this jumbled webpage into something more clear and
informative for your readers! Look at the way you used block elements to chunk
• To get started, you will need two files - the CSS you need to include in your HTML
and the raw text for the letter.
• Create a new .html file using your text editor to do your work in
• You don't need to know any CSS to do this assessment; you just need to put the
provided CSS inside an HTML element.
• Use the W3C HTML validator to validate your HTML - [Link]
Block/structural semantics:
• You should structure the overall document with an appropriate structure including
doctype, and <html>, <head> and <body> elements.
• The letter in general should be marked up with a structure of paragraphs and
headings, with the exception of the below points. There is one heading (the "Re:"
line) and three second level headings.
• The semester start dates, study subjects and exotic dances should be marked up
using an appropriate list type.
• The two addresses can just be put inside paragraphs. The <address> element is not
appropriate for them — think about why. In addition, each line of the addresses
should sit on a new line, but not be in a new paragraph.
Inline semantics:
• The names of the sender and receiver (and "Tel" and "Email") should be marked up
with strong importance.
• The first address and first date in the letter should be given a class attribute value of
"sender-column"; the CSS you'll add later will then cause these to be right aligned, as
should be the case in a classic letter layout.
• The five acronyms/abbreviations in the main text of the letter should be marked up to
provide expansions of each acronym/abbreviation.
• Try to mark up at least two appropriate words in the text with strong
importance/emphasis.
• There are two places where a hyperlink should be added; add appropriate links with
titles. For the location that the links point to, just use [Link]
• The university motto quote and citation should be marked up with appropriate
elements.
• The character set of the document should be specified as utf-8 using an appropriate
meta tag.
• The author of the letter should be specified in an appropriate meta tag.
• The provided CSS should be included inside an appropriate tag.
• A header spanning the full width of the site containing the main title for the page, the
site logo, and the navigation menu. The title and logo appear side by side once
styling is applied, and the navigation appears below those two items.
• A main content area containing two columns - a main block to contain the welcome
text, and a sidebar to contain image thumbnails.
• The provided CSS is designed so that when the correct structural elements are
added to the mark-up, they will appear green in the rendered page.
Example
The following screenshot shows an example of what the homepage might look like after
being marked up.
Note
HTML5 introduced new structurally based elements, including
the <header>, <nav>, <article>, <section>, <aside>, and <footer> elements.
All of these new elements are intended to give meaning to the organisation of our pages and
improve our structural semantics. They are all block-level elements and do not have any
Block-level elements may be nested inside one another and may wrap inline-level elements.
We’ll most commonly see block-level elements used for larger pieces of content, such as
paragraphs.
Inline-level elements do not begin on a new line. They fall into the normal flow of a
document, lining up one after the other, and only maintain the width of their content. Inline-
level elements may be nested inside one another; however, they cannot wrap block-level
elements. We’ll usually see inline-level elements with smaller pieces of content, such as a
few words.
HTML: Hypertext Markup Language, the language of the web, the skeleton of a webpage.
Tag: an HTML label that identifies an element on a webpage, like <p> identifies a
paragraph.
Opening Tag: the tag that begins part of a webpage, like <p> before a paragraph.
Closing Tag: the tag that ends part of a webpage with a slash, like </p> to end a paragraph.
Value: the value for an attribute, like “red” for “color” or “12px” for “font-size”.
CodePen
[Link]
W3 Schools - HTML
[Link]
HTML CheatSheet
[Link]
HTML Templates
[Link]
Exercises & Breakouts sourced from W3 Schools, Mozilla Development & HTML
Quick.
Introduction to CSS 68
• What is CSS
• History
• Background
• CSS example I
• Reflection exercise
CSS Structure 72
• Structure
• How does CSS affect HTML?
• How does CSS work?
• How to apply your CSS to your HTML
• CSS Example II
• CSS syntax
• CSS declarations
• Beyond syntax: make CSS readable
• Reflection exercise
Selectors 82
• Introduction to selectors
• Different types of selectors
• Simple selectors
• Pseudo-classes and pseudo-elements
CSS Units 86
• CSS units
• Reflection exercise
Cascade 89
Styling Text 92
• Font properties - style, font weight
• Text properties - colour, text-align, vertical-align
• Text layout - alignment and line height
• Reflection exercise
What is CSS?
CSS (Cascading Style Sheets) is a language that describes the style of an HTML document.
CSS describes how HTML elements should be displayed.
History
CSS was first developed in 1997 as a way for web developers to define the visual
appearance of the web pages that they were creating. It was intended to allow web
professionals to separate the content and structure of a website's code from the visual
design, something that had not been possible prior to this time.
The separation of structure and style allows HTML to perform more of its original function,
the markup of content, without having to worry about the design and layout of the page itself,
something commonly known as the "look and feel" of the page.
Background
HTML was NEVER intended to contain tags for formatting a web page. HTML was created
to describe the content of a web page, like:
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
The style definitions are normally saved in external .css files. With an external stylesheet file,
you can change the look of an entire website by changing just one file!
CSS Example
The CSS Zen Garden is a World Wide Web development resource "built to demonstrate
what can be accomplished visually through CSS-based design." Style sheets contributed by
designers from around the world are used to change the visual presentation of a single
HTML file, producing hundreds of different designs.
Explore the CSS Zen Garden example files which are supplied - HTML and CSS file. Visit
the CSS zen website to view different designs. Clicking on any one will load the style sheet
into this very page. The HTML remains the same, the only thing that has changed is the
external CSS file. A demonstration of what can be accomplished through CSS-based design.
[Link]
A document is usually a text file structured using a markup language - HTML is the most
common markup language, but you will also come across other markup languages such
as SVG or XML.
Presenting a document to a user means converting it into a usable form for your
audience. Browsers, like Firefox, Chrome or Internet Explorer, are designed to present
documents visually, for example, on a computer screen, projector or printer.
• A set of properties, which have values set to update how the HTML content is
displayed, for example, the element's width is 50% of its parent element, and its
background to be red.
• A selector, which selects the element(s) you want to apply the updated property
values to. For example, the application a CSS rule to all the paragraphs in a HTML
document.
A set of CSS rules contained within a stylesheet determines how a webpage should look.
The second rule starts with a p selector, which means that it will apply its property values to
the <p> element. It contains one declaration, which sets the text colour to red.
In a web browser, the code above would produce the following output:
1. The browser converts HTML and CSS into the DOM (Document Object Model). The
DOM represents the document in the computer's memory. It combines the
document's content with its style.
External stylesheet
You've already seen external stylesheets previously, but not by that name. An external
stylesheet is when you have your CSS written in a separate file with a .css extension, and
you reference it from an HTML <link> element. The HTML file looks something like this:
Internal stylesheet
An internal stylesheet is where you don't have an external CSS file, but instead place your
CSS inside a <style> element, contained inside the HTML head. So the HTML would look
like this:
This can be useful in some circumstances (maybe you're working with a content
management system where you can't modify the CSS files directly), but it isn't quite as
Inline styles
Inline styles are CSS declarations that affect one element only, contained within a style
attribute:
The only time you might have to resort to using inline styles is when your working
environment is really restrictive (perhaps your CMS only allows you to edit the HTML body).
CSS syntax
At its most basic level, CSS consists of two building blocks:
Values: Each specified property is given a value, which indicates how you want to
change those stylistic features (e.g. the font, width or background colour).
A property paired with a value is called a CSS declaration. CSS declarations are put
within CSS Declaration Blocks. CSS declaration blocks are paired with selectors to
produce CSS Rulesets (or CSS Rules).
Declarations are grouped in blocks, with each set of declarations being wrapped by opening
curly brackets { and a closing one }.
We are missing one part of the puzzle - we need to discuss how to tell our declaration blocks
which elements they should be applied to. This is done by prefixing each declaration block
with a selector — a pattern that matches some elements on the page. The associated
declarations will be applied to those elements only. The selector plus the declaration block is
called a ruleset or a rule.
White space
White space means actual spaces, tabs and new lines. You can add white space to make
your stylesheets more readable. In the same manner as HTML, the browser tends to ignore
much of the whitespace inside your CSS; a lot of the whitespace is just there to aid
readability.
Comments
As with HTML, you are encouraged to make comments in your CSS, to help you understand
how your code works when coming back to it after several months, and to help others
understand it. Comments are also useful for temporarily commenting out certain parts of the
code for testing purposes, for example if you are trying to find which part of your code is
causing an error. Comments in CSS begin with /* and end with */.
To recap, selectors are one part of a CSS rule and come just before CSS declaration blocks.
• Simple selectors: Match one or more elements based on element type, class, or id.
• Pseudo-classes: Match one or more elements that exist in a certain state, such as an
element that is being hovered over by the mouse pointer, or a checkbox that is
currently disabled or checked, or an element that is the first child of its parent in the
DOM tree.
• Pseudo-elements: Match one or more parts of content that are in a certain position in
relation to an element, for example the first word of each paragraph, or generated
content appearing just before an element.
• Combinators: These are not exactly selectors themselves, but ways of combining two
or more selectors in useful ways for very specific selections. So for example, you
could select only paragraphs that are direct descendants of divs, or paragraphs that
come directly after headings.
Simple selectors
Type selectors /element selectors
This selector is just a case-insensitive match between the selector name and a given HTML
element name. This is the simplest way to target all elements of a given type. Let's take a
look at an example:
Class selectors
The class selector consists of a dot, '.', followed by a class name. A class name is any value,
without spaces, placed within an HTML class attribute. It is up to you to choose a name for
the class. It is also noteworthy that multiple elements in a document can have the same
class value, and a single element can have multiple class names separated by white space.
ID selectors
The ID selector consists of a hash/pound symbol (#), followed by the ID name of a given
element. Any element can have a unique ID name set with the id attribute. It is up to you to
choose an ID name. It's the most efficient way to select a single element.
Pseudo-classes
A CSS pseudo-class is a keyword added to the end of a selector, preceded by a colon (:),
which is used to specify that you want to style the selected element but only when it is in a
certain state. For example, you might want to style a link element only when it is being
hovered over by the mouse pointer, or a checkbox when it is disabled or checked. For
example:
• :active
• :checked
• :default
• :dir
• :disabled
• :empty
• :enabled
We will look into every pseudo-class right now but here is a simple example.
Pseudo-elements
Pseudo-elements are very much like pseudo-classes, but they have differences. They are
keywords, this time preceded by two colons :: , that can be added to the end of selectors to
select a certain part of an element.
• ::after
• ::before
• ::first-letter
• ::first-line
• ::selection
• ::backdrop
They all have some very specific behaviours and interesting features.
• Many CSS properties take "length" values, such as width, margin, padding, font-size,
etc.
• A whitespace cannot appear between the number and the unit. However, if the value
is 0, the unit can be omitted.
Absolute Lengths
The absolute length units are fixed and a length expressed in any of these will appear as
exactly that size.
Absolute length units are not recommended for use on screen, because screen sizes vary so
much. However, they can be used if the output medium is known, such as for print layout.
Unit Description
cm centimetres
mm millimetres
Relative Lengths
Relative length units specify a length relative to another length property. Relative length units
scales better between different rendering mediums.
Unit Description
em Relative to the font-size of the element (2em means 2 times the size of the
current font)
The Cascade
CSS is an abbreviation for Cascading Style Sheets, which indicates that the notion of the
cascade is important. At its most basic level, it indicates that the order of CSS rules matter,
but it's more complex than that. What selectors win out in the cascade depends on three
factors (these are listed in order of weight - earlier ones will overrule later ones):
• Importance
• Specificity
• Source order
Importance
In CSS, there is a special piece of syntax you can use to make sure that a certain
declaration will always win over all others: !important.
All HTML elements can be considered as boxes. In CSS, the term "box model" is used when
talking about design and layout.
The CSS box model is essentially a box that wraps around every HTML element. It consists
of: margins, borders, padding, and the actual content. The image below illustrates the box
model:
The box model allows us to add a border around elements, and to define space between
elements.
The CSS properties used to style text generally fall into two categories, which we'll look at
separately:
Font styles: Properties that affect the font that is applied to the text, affecting what
font is applied, how big it is, whether it is bold, italic, etc.
Text layout styles: Properties that affect the spacing and other layout features of the
text, allowing manipulation of, for example, the space between lines and letters, and
how the text is aligned within the content box.
Font Properties
The CSS font properties define the font family, weight, size, and the style of a text.
CSS provides four common properties to alter the visual weight/emphasis of text:
• font-style: Used to turn italic text on and off. Possible values are as follows (you'll
rarely use this, unless you want to turn some italic styling off for some reason):
o normal: Sets the text to the normal font (turns existing italics off.)
o italic: Sets the text to use the italic version of the font if available; if not
available, it will simulate italics with oblique instead.
o oblique: Sets the text to use a simulated version of an italic font, created
by slanting the normal version.
• font-weight: Sets how bold the text is. This has many values available in case you
have many font variants available (such as -light, -normal, -bold, -extrabold, -black,
etc.), but realistically you'll rarely use any of them except for normal and bold:
o normal, bold: Normal and bold font weight
o lighter, bolder: Sets the current element's boldness to be one step lighter or
heavier than its parent element's boldness.
o 100–900: Numeric boldness values that provide finer grained control than the
above keywords, if needed.
• The font-size Property: The font-size property sets the size of a font.
alue Description
baseline The element is aligned with the baseline of the parent. This is default
sub The element is aligned with the subscript baseline of the parent
super The element is aligned with the superscript baseline of the parent
top The element is aligned with the top of the tallest element on the line
text-top The element is aligned with the top of the parent element's font
bottom The element is aligned with the lowest element on the line
text- The element is aligned with the bottom of the parent element's font
bottom
Text layout
With basic font properties out the way, let's now have a look at properties we can use to
affect text layout.
Text alignment
The text-align property is used to control how text is aligned within its containing content box.
The available values are as follows, and work in pretty much the same way as they do in a
regular word processor application:
Line height
The line-height property sets the height of each line of text — this can take most length and
size units, but can also take a unitless value, which acts as a multiplier and is generally
considered the best option — the font-size is multiplied to get the line-height. Body text
generally looks nicer and is easier to read when the lines are spaced apart; the
recommended line height is around 1.5–2 (double spaced.) So to set our lines of text to 1.5
times the height of the font, you'd use this:
Use the space below to write five things about styling text:
1.
2.
3.
4.
5.
CSS Outline
An outline is a line that is drawn around elements, OUTSIDE the borders, to make the
element "stand out".
• outline-style
• outline-color
• outline-width
• outline-offset
• outline
The following example shows some different outlines with different colours. Also notice that
these elements also have a thin black border inside the outline:
The outline property is specified as one, two, or three values from the list above. The order
of the values does not matter.
The following example shows some outlines specified with the shorthand outline property:
Outline Offset
The outline-offset property adds space between an outline and the edge/border of an
element. The space between an element and its outline is transparent.
The following example specifies an outline 15px outside the border edge:
Each technique has its uses, advantages, and disadvantages, and no technique is designed
to be used in isolation. By understanding what each method is designed for you will be in a
good place to understand which is the best layout tool for each task.
Normal Flow
Normal flow is how the browser lays out HTML pages by default when you do nothing to
control page layout.
The elements that appear one below the other are described as block elements, in contrast
to inline elements, which appear one beside the other, like the individual words in a
paragraph.
When you use CSS to create a layout, you are moving the elements away from the normal
flow, but for many of the elements on your page the normal flow will create exactly the layout
you need. This is why starting with a well-structured HTML document is so important, as you
can then work with the way things are laid out by default rather than fighting against it.
The methods that can change how elements are laid out in CSS are as follows:
• The display property - Standard values such as block, inline or inline-block can
change how elements behave in normal flow. We then have entire layout methods
that are switched on via a value of display, for example CSS Grid and Flexbox.
• Floats - Applying a float value such as left can cause block level elements to wrap
alongside one side of an element, like the way images sometimes have text floating
around them in magazine layouts.
• The position property - Allows you to precisely control the placement of boxes
inside other boxes. static positioning is the default in normal flow, but you can cause
elements to be laid out differently using other values.
• Multi-column layout - The multi-column layout properties can cause the content of a
block to layout in columns, as you might see in a newspaper.
You can change this default display behaviour. For example, the <li> element is display:
block by default, meaning that list items display one below the other in our English
document. If we change the display value to inline they now display next to each other, as
words would do in a sentence. The fact that you can change the value of display for any
element means that you can pick HTML elements for their semantic meaning, without being
concerned about how they will look. The way they look is something that you can change.
In addition to being able to change the default presentation by turning an item
from block to inline and vice versa, there are some bigger layout methods that start out as a
value of display. However when using these you will generally need to invoke additional
properties. The two values most important for our purposes when discussing layout
are display: flex and display: grid.
The HTML markup in the example below gives us a containing element, with a class
of wrapper, inside which are three <div> elements. By default these would display as block
elements, below one another, in our English language document.
However, if we add display: flex to the parent, the three items now arrange themselves into
columns. This is due to them becoming flex items and using some initial values that flexbox
gives them. They are displayed as a row, because the initial value of flex-direction is row.
They all appear to stretch to the height of the tallest item, because the initial value of
the align-items property is stretch. This means that the items stretch to the height of the flex
container, which in this case is defined by the tallest item. The items all line up at the start of
the container, leaving any extra space at the end of the row.
Open the Flexbox sample files above (HTML & CSS) in folder supplied.
In addition to the above properties that can be applied to the flex container, there are
properties that can be applied to the flex items. These properties, among other things, can
change the way that the items flex, enabling them to expand and contract to fit into the
available space.
Once again, you can switch on Grid Layout with a specific value of display — display: grid.
The below example uses similar markup to the flex example, with a container and some
child elements. In addition to using display: grid, we are also defining some row and column
tracks on the parent using the grid-template-rows and grid-template-columns properties
respectively. We've defined three columns each of 1fr and two rows of 100px. I don’t need to
put any rules on the child elements; they are automatically placed into the cells our grid has
created.
Open the Grid 1 example above (HTML & CSS) in folder supplied.
Once you have a grid, you can explicitly place your items on it, rather than relying on the
auto-placement behaviour seen above. In the second example below we have defined the
same grid, but this time with three child items. We've set the start and end line of each item
using the grid-column and grid-row properties. This causes the items to span multiple tracks.
Open the Grid 2 example above (HTML & CSS) in folder supplied.
There are other layout methods, which are less important for the main layout structures of
your page but can still help you achieve specific tasks. These include floats and positioning.
Introduction
• Responsive web design makes your web page look good on all devices.
• Responsive web design uses only HTML and CSS.
• Responsive web design is not a program or a JavaScript.
Desktop
Phone
It is called responsive web design when you use CSS and HTML to resize, hide, shrink,
enlarge, or move the content to make it look good on any screen.
Sourced from
1. Have a look at the box model of each individual element on the page by opening up
the browser developer tools and clicking on the elements in the DOM inspector.
Each browser has a box model viewer that shows exactly what margin, border and
padding is applied to each box, how big the content box is, and the total space the
element takes up.
2. Set some margin-bottom on the <main> element, say 20px. Now set some margin-
top on the <footer> element, say 15px. Note how the 2nd one of these actions
3. Set a margin of 30px and a padding of 30px on every side of the <main> element —
note how the space around the element (the margin) and the space between the
border and the content (the padding) both increase, causing the actual content to
take up a smaller amount of space. Again, check this with the browser developer
tools.
4. Set a larger border on all sides of the <main> element, say 40px, and notice how this
takes space away from the content rather than the margin or padding. You could do
this by setting a complete new set of values for the width, style and color with
the border property, e.g. 60px dashed red, but since the properties are already set in
a previous rule, you could just set a new border-width.
5. By default, the content width is set to 100% of the available space (after the margin,
border, and padding have taken their share) — if you change the browser window
width, the boxes will grow and shrink to stay contained inside the example output
window. The height of the content will default to the height of the content inside it.
6. Try setting a new width and height on the <main> element - start with say 400px width
and 200px height - and observe the effect. You'll notice that the width no longer
changes as the browser window is resized.
7. Try setting a percentage width on the <main> element instead - say 60% width - and
observe the effect. You should see that the width now changes again as the browser
window is resized. Remove the <main> element's height setting for now.
8. Try setting your <main> element's padding and margin to be 5% on all sides, and
observe the result. If you use your browser developer tools to look at the width of the
example output window and compare that to the width of the margin/padding, you'll
see that this 5% means "5% of the containing element's width." So as the size of the
example output window increases, so does the padding/margins.
Basic setup:
1. First of all, create a new file in the same directory as your HTML and image files. Call
it something really imaginative like [Link].
3. The first two rulesets in the CSS resource file are yours, for FREE! After you've
finished rejoicing at your good fortune, copy and paste them into the top of your new
CSS file. Use them as a test to make sure your CSS is properly applied to your
HTML.
4. Above the two rules, add a CSS comment with some text inside it to indicate that this
is a set of general styles for the overall page. "General page styles" would do. Also
add three more comments at the bottom of the CSS file to indicate styles specific to
the setup of the card container, styles specific to the header and footer, and styles
specific to the main business card contents. From now on, subsequent styles added
to the stylesheet should be organized in an appropriate place.
5. Taking care of the selectors and rulesets provided in the CSS resource file.
6. Next up, we'd like you to look at the four selectors, and calculate the specificity for
each one. Write these down somewhere where they can be found later on, such as in
a comment at the top of your CSS.
9. Give the header a background gradient that goes from darker to lighter, plus rounded
corners that fit in with the rounded corners set on the main card container.
10. Give the footer a background gradient that goes from lighter to darker, plus rounded
corners that fit in with the rounded corners set on the main card container.
11. Float the image to the right so that it sticks to the right hand side of the main
business card contents, and give it a max-height of 100% (a clever trick that ensures
that it will grow/shrink to stay the same height as its parent container, regardless of
what height it becomes).
12. Beware! There are two errors in the provided rulesets. Using any technique that you
know, track these down and fix them before moving on.
a. Write a ruleset that targets both the card header, and card footer, giving
them both a computed total height of 50px (including a content height of
30px and padding of 10px on all sides.) But express it in ems.
b. The default margin applied to the <h2> and <p> elements by the browser
will interfere with our design, so write a rule that targets all these elements
and sets their margin to 0.
c. To stop the image from spilling out of the main business card content
(the <article>element), we need to give it a specific height. Set
the <article>'s height to 120px, but expressed in ems. Also give it a
d. Write a ruleset that gives the <h2> an effective font size of 20px (but
expressed in ems) and an appropriate line height to place it in the centre of
the header's content box. Recall from earlier that the content box height
should be 30px - this gives you all the numbers you need to calculate the
line height.
e. Write a ruleset that gives the <p> inside the footer an effective font size of
15px (but expressed in ems) and an appropriate line height to place it in
the centre of the footer's content box. Recall from earlier that the content
box height should be 30px — this gives you all the numbers you need to
calculate the line height.
Roughwork.
Fonts:
• First of all, download a couple of free-to-use fonts. Because this is a School, the fonts
should be chosen to give the page a fairly serious, formal, trustworthy feel — a serif
site-wide font for the general text body, coupled with sans-serif or slab serif for the
headings might be nice.
• Use a suitable service to generate bulletproof @font-face code for these two fonts.
• Apply your body font to the whole page, and your heading font to your headings.
Links:
• Give the link, visited, focus, and hover states some colors that go with the color of the
horizontal bars at the top and bottom of the page.
• Make it so that links are underlined by default, but when you hover or focus them, the
underline disappears.
• Remove the default focus outline from ALL the links on the page.
Lists:
• Make sure the spacing of your lists and list items works well with the styling of the
overall page. Each list item should have the same line-height as a paragraph line,
and each list should have the same spacing at its top and bottom as you have
between paragraphs.
• Give your list items a nice bullet, appropriate for the design of the page. It is up to
you whether you choose a custom bullet image or something else.
Navigation menu:
• Style your navigation menu so that it has an appropriate look for the look and feel for
the page.
The following screenshot shows an example of what the finished design could look like:
The logo
• To the <h1>, add the logo as a background image.
• Add a filter to the logo to give it a subtle drop shadow.
• Now comment out the filter and implement the drop shadow in a different (slightly
more cross-browser compatible) way, which still follows the shape of the round
image.
Roughwork.
General task
Apply the CSS to the HTML.
The following screenshot shows an example of what the finished design could look like:
Basic Setup
• You can download all the required files in the folder supplied.
• Save the HTML document and stylesheet into a directory on your computer, and add
the images into a folder named images. Opening the [Link] file in a browser
should give you a page with basic styling but no layout, which should look something
like the image seen below.
• This starting point has all of the content of your layout as displayed by the browser in
normal flow.
You do not need to edit the HTML in order to achieve this layout and the techniques you
should use are:
• Positioning
• Float
• Flexbox
Roughwork.
[Link]
CodePen Tool
[Link]
CSS Exercises
[Link]
W3 Schools
[Link]
Mozilla Development
[Link]
Listing the most useful free online tools and resources for web developers
[Link]
Exercises & Breakouts sourced from W3 Schools, Mozilla Development, Free Code
Camp.
UX Design
• UX Design 128
• UX Resources 144
[Link]
Products that provide great user experience (e.g., the iPhone) are thus designed with not
only the product’s consumption or use in mind but also the entire process of acquiring,
owning, and even troubleshooting it. Similarly, UX designers don’t just focus on creating
products that are usable; they concentrate on other aspects of the user experience, such as
pleasure, efficiency and fun. Consequently, there is no single definition of a good user
experience. Instead, a good user experience is one that meets a particular user’s needs in
the specific context.
2 - Product investigation
Here, we can discuss the info we got from the marketing department and how we can place
the product on the market. We discuss aspects like potential age of the user, his financial
status, IT knowledge, and field of work (banks, municipality etc.).
4 - Concept
Having the package ready, the next step is to create the architecture of the app, or better
said the site map. Based on this, we can start sketching the wireframes to create a better
5 - Prototype
Now we can start creating a prototype based on the wireframes, so we can provide a nice
flow to the app. This should be a clickable model and emulate the general functionality. This
is a very important step for UI/UX designers who choose to skip UX and jump to the UI part.
They are sometimes successful at making a good impression on the client, but this move will
have a negative impact and slow down the overall process.
6 - The Visual
Once we have agreed on the prototype and the functionality, we can finally move to the user
interface part. This can be done easily since we already have a prototype. The artistic part
can be done with transitions and animations but also by the design approach decided upon
(Material, iOS, Flat or a combination).
Don Norman
Visibility
The more visible functions are, the more likely users will be able to know what to do next. In
contrast, when functions are out of sight, it makes them more difficult to find and know how
to use.
Feedback
Feedback is concerned with sending back information about what action has been done and
what has been accomplished, allowing the person to continue with the activity. Various kinds
of feedback are available for interaction design-audio, tactile, verbal, and combinations of
these.
Constraints
The design concept of constraining refers to determining ways of restricting the kind of user
interaction that can take place at a given moment. There are various ways this can be
achieved.
Consistency
This refers to designing interfaces to have similar operations and use similar elements for
achieving similar tasks. In particular, a consistent interface is one that follows rules, such as
using the same operation to select all objects. For example, a consistent operation is using
the same input action to highlight any graphical object at the interface, such as always
clicking the left mouse button. Inconsistent interfaces, on the other hand, allow exceptions to
a rule.
Affordance
A term used to refer to an attribute of an object that allows people to know how to use it. For
example, a mouse button invites pushing (in so doing acting clicking) by the way it is
physically constrained in its plastic shell. At a very simple level, to afford means to give a
clue (Norman, 1988). When the affordances of a physical object are perceptually obvious it
is easy to know how to interact with it.
[Link]
Jakob Nielsen
Author of the quintessential usability checklist Ten Usability Heuristics and an early
champion of usability testing, Jakob Nielsen was recognized as the "Guru of Usable Web
Pages " by the New York Times.
[Link]
Error prevention
Even better than good error messages is a careful design which prevents a problem from
occurring in the first place. Either eliminate error-prone conditions or check for them and
present users with a confirmation option before they commit to the action.
These principles can help you create a well-designed User Interface and thereby improve
the usability of the system.
Source: Designing the User Interface: Strategies for Effective Human-Computer Interaction
UX Glossary
Review Pol Kuijken’s case study on his ‘Google Design Exercise: Solving the shelter’
problem when he was applying for a position at Google.
[Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
damentals__Learn_the_Basics_of_IA_UX_and_UI_Design.pdf
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]