8 – HTML – Styles

Styling HTML

In the previous section, we added the Style attribute to alter the appearance of some of the HTML elements. The Style attribute is one of the ways we can add CSS properties and values to HTML.

CSS (Cascading Style Sheets) defines how an HTML element should be displayed and can be applied in three different ways:

  • Inline CSS styles – using the style attribute
  • Internal CSS styles – defining CSS styles in the <head> of the HTML document
  • External CSS stylesheet -linking an external CSS file to the HTML document

Inline CSS styles

For the examples in the previous article, we used the style attribute to add inline styles to a short piece of HTML code. 

The style attribute is used to set the CSS property and value.

The syntax for style attribute includes the attribute, property : and the value of the property followed by a closing semi colon ;.

<h1 style=”property: value;”>Headline</h1>

For example, to change the colour of a headline we add the style attribute to the headline tag (h1), set the property to color: and the value to red;

<h1 style=”color: red;>Red Headline</h1>
Result

Headline

Additional CSS properties and values are added by adding more CSS  property:value;  Remember to include : to each property and ; to the end of each value.

<h1 style=”color: red; text-align:center;>Red Headline</h1>
Result

Headline

Internal CSS styles

Internal styles are used to define CSS properties and values for a single HTML document (page).

Internal styles are added to the <head> section of the HTML document using the <style> tag.

<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<h1>Blue Headline</h1>
<p>This is a simple paragraph</p>
</body>
</html>

Inside the <style> tag we add the CSS selector (element, class or id) and CSS properties and values for each element to be adjusted from its default or inherited state. Each selector is followed by the property and value placed between { } curly brackets (braces). Additional properties and values can be added after each semicolon (;).

<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:blue;}
h2 {color:grey;}
</style>
</head>
<body>
<h1>Blue Headline</h1>
<p>This is a simple paragraph</p>
</body>
</html>

Internal styles apply styles only to a single document (page), to add styles to multiple pages without having to repeat the CSS styles on each page we should use external style sheets.

External CSS

An external CSS is a document which contains only CSS syntax and includes all styling information to format the HTML content.

To link the external CSS to the HTML we use the self closing link tag <link> with path to the CSS file href="filename.css",  followed by the rel (relationship) rel="stylesheet" and the type of file (MIMEtype="text/css".

<link href="filename.css" rel="stylesheet" type="text/css">

This link is added to the <head> section of the HTML document.

<!DOCTYPE html>
<html>
<head>
<link href="styles.css "rel="stylesheet" type="text/css">
</head>
<body>
<h1>Blue Headline</h1>
<p>This is a simple paragraph</p>
</body>
</html>

An external CSS document includes the properties and values for each of the HTML elements. In the CSS document, each element is named using its selector followed by its CSS properties and values written between { curly brackets (braces) }.

body {
background-color: lightgrey;
h1{
color: blue;
}
p {
color: grey;
}

It is nearly always best to link to an external CSS file, rather than use inline styles or internal styles, as this makes HTML and CSS easier to maintain and update. However, for small single uses it may be helpful to use inline or internal style to reduce the number of server request for the external CSS document. 

As a general rule, HTML document should be used only for content and an external CSS document should be used for presentation. 


 

Next step 
HTML – 9 – Semantics

 

7 – HTML – Divs, Spans, Classes, Ids

HTML has three types of elements, the Block-Level (Block) elements or Inline elements and the Empty (Self Closing) element.

These elements can be divided into related areas using Div and Span.

Classes and IDs are used to identify these elements so they can be targeted for styling, layout and function.

Block and Inline

Let’s start by exploring what is the main difference between Block level and Inline elements.

Block level elements extending across the full width of the area the block element is placed. Each addition block element appears below the previous one.

Inline elements appear next to each to each other on either the left or right and can start anywhere on a line.

Block

The example below illustrates how two Block level elements appear together. Here we use a headline followed by a paragraph block element.

<h1 style="background-color: yellow;">This is a headline</h1>
<p style="background-color: lightgrey;">This is a paragraph of text</p>
Result

This is a headline

This is a paragraph of text

By using a different background colour for each block level element we can clearly see how the block level element appears across the full width of the available area and not just around the text.

HTML Block level elements include:

p
h1, h2, h3, h4, h5, h6
ol, ul
pre
address
blockquote
dl
div
fieldset
form
hr
noscript
table

Inline

Inline elements appear next to each other as shown in the example below. In this example, each inline elements has a different coloured background showing the space each inline element occupies.

<h1>
<span style="background-color: yellow;">Yellow</span>
<span style="background-color: red;">Red</span>
<span style="background-color: blue;">Blue</span>
</h1>
Result

YellowRedBlue

In the second example below, a lightgrey background colour applied to the H1 element, showing the inline elements still appear within the H1 block level element.

<h1 style="background-color:lightgrey;"
<span style="background-color: yellow;">Yellow</span>
<span style="background-color: red;">Red</span>
<span style="background-color: blue;">Blue</span>
</h1>
Result

YellowRedBlue

HTML Inline elements include:

a
img
b
strong
i
em
q
small
big
code
span
button
input
label
select
script
sub
sup
textarea

Empty element

Empty elements are HTML elements without any content, such a line break <br> or <br />. These elements do not require a closing tag as they are empty elements.

HTML Empty elements include:

<area>
<base>
<br>
<col>
<embed>
<hr>
<img>
<link>
<meta>
<source>
<track>

Divs and Spans

HTML can be divided into groups of elements using  <div> for Block level elements and <span> for Inline elements.

Div

Div (division) allows a number of block level elements to be grouped together in a container which can simplify the organisation, layout and styling of the HTML document.

The <div> tag is used at the beginning of the div element and requires a closing tag </div> at the end. Nested inside the Div are all the related block level elements.

The example below shows a div container used to group two block level elements.

<div class="special-offer">
<h2>Special Offer</h2>
<p>Get 10% off your next order</p>
</div>

Grouping elements into Divs enables the grouped elements to have related CSS styling, positioning and functionality applied.

Span

Spans are used to define a selection of an inline element. The opening <span> tag is applied at the start of the selected content and the closing </span> at the end.

Spans applied in the example below have a different colour applied to the word red and blue.

<h1>
<h1 style="color: grey;">Roses are
<span style="color: red;">Red</span>
Violets are <span style="color: blue;">Blue...</span>
</h1>
Result

Roses are Red
Violets are Blue…

Spans shouldn’t be used often and it is better to use where possible classes or ids to target inline elements.


Classes and IDs

Class and Id are hooks that are used to identify HTML elements within a document so they can be targeted for styling in CSS or manipulation by another language like JavaScript.

id="name-of-id"
class="name-of-class"

These hooks can be applied to any HTML element, for example, a paragraph.

<p class="highlighted">This is a paragraph we want to target with the 'highlight' class within our css.</p>
<p id="special">This is a paragraph we want to target with the 'special id' class within our css or javascript.</p>

An element can have both an ID and a Class.

<p id="special" class="red-text">This is a paragraph with a special id and class of red-text.</p>

Classes

Classes can be applied to elements that appear more than once in an HTML document. Classes are used when the existing semantics definition of an element is not enough. For example, if you want different colours for paragraphs of text.

<p>This is the first paragraph of text.</p>
<p class="red-text">This is the second paragraph of text.</p>

The same class can be used multiple times on multiple elements.

Classes should be used for elements which have repeatable characteristics.

IDs

IDs are used for targeting unique items in the HTML document. Only one ID can be used per element and this ID can be used only once per page.

IDs can be used for styling CSS but classes should probably be used together with an ID for added clarity in the markup.

IDs have an additional useful feature which is the ‘hash-value’ in the URL. When a web address appears with a hashtag, eg. www.points-pixels.com#links, then the browser will try to locate an ID with this name (links) in the HTML document and automatically scroll to this point on the page.

<p id="links">This is a list of links</p>
<ul>
<li> Link one</li>
<li> Link two</li>
<li> Link three</li>
</ul>

 

IDs should be used for unique items that appear only once per page.

 


 

Next step 
HTML – 8 – Style

6 – HTML – Forms

Forms

Forms send data from the user to a server for processing. They allow the user to pass on a small or large amount of information in a controlled and standardised way.

Forms can be short like requesting the name and email address of a user or longer such as an online bank loan application. 

All forms should be designed and written to be easy to understand, simple to complete and also give the user predictable feedback. 

Simple Forms

Each form contains form elements. Each element has an information request <label> and an <input> area for the user to respond. More simply, the label is the question and the input is where user answers the question.

This example shows a basic contact form which has two input fields with labels and a submit button.

Result




Note: this website applies CSS styling to the results area, so most form elements will render differently from the default views.

<form>
<label for="name">Name</label>
<input name="name" type="text"/>
<label for="email">Email</label>
<input name="email" type="email"/>
<input type="submit"/>
</form>

Form

Form defines a group of form elements and how information inputted from the form elements is transferred to a server.

The <form> tag is used as a wrapper to define all the form elements nested inside as part of the form. Forms must be closed with the </form> end tag.

Label

The <label> is a text information request which is associated with a form input or control.

Each label should relate to the information being gathered, so <label> should be followed by for (which field does it belong to), followed by the Label text (what text appears above the label) and then the closing </label> tag.

<label for="input-field">Label text</label>

Input

The <input>  is where the user responds to a request for information.

The <input> element defines the form interaction area, inside this is are added the form attributes such as the type (control), name and value.

<input type="text">

Input type

Forms inputs have a selection of controls for collecting and sending data. In HTML these define the input types as either text input, checkboxes, radio buttons, menus, file selection and buttons.

<input type="control-goes-here">

A full list of input types can be found below.

Naming the input

The name attribute is used as a reference for the data collected in the input and it must be added for information to be passed to a server.

<input type="text" name="name-goes-here">

More attributes

Additional attributes can be applied to define the input functionality. This includes autocomplete, autofocus, checked, disabled, placeholder, required and value.

For a complete list of attribute visit Mozilla.org

 


Form elements

So far we have looked at simple text forms, but HTML allows for many more ways to define how form elements function. Here are a few examples of the most common ones.

Placeholder

Placeholder text enables temporary information to be displayed in the input text field, this can provide additional instructions to help the user enter the correct type of content or format the content correctly.

<form>
<label>This is text field:</label>
<input name="your_name" type="text" placeholder="Enter your text" />
</form>
Result

Placeholders should never be used instead of labels as this can lead to the user being confused as information entered replaces the placeholder.

Password

Passwords included sensitive information and should be obscured. To define a password input we use <input type="password" /> this changes any text, number or symbol typed into an input field to either a * or characters.

<form>
<label>Password:</label>
<input name="password" type="password" />
</form>
Result

Submit and Reset Buttons

Adding a button to a form requires the use of <input type="button">. This will add a clickable button to a form but if we want to reset inputted form data to its initial values or submit information from the form to a server we should use  <input type="reset"> and <input type="submit">.

<form>Enter your text:
<input name="your_name" type="text" />
<input name="submit" type="reset" value="Reset" /> <input name="submit" type="submit" value="Submit" />
</form>
Result
Enter your text:

The text displayed on the input button can be changing by altering the text in the value attribute.

Dropdown

Dropdown menus offer the user a list of options to select from.

The <select> element defines the input menu, <option> is used to define each choice in the list. Setting a list item to disabled will display the list item in a subdued way, usually grey and this list item will be unselectable.

<form>
<label for="options-list">A list of options:</label>
<select name="options-list">
<option disabled="disabled" selected="selected" value="options">Select an option</option>
<option value="options">Option 1</option>
<option value="options">Option 2</option>
<option value="options">Option 3</option>
</select>
</form>
Result

Additional settings include selected for pre-selecting an option, size to display more than one item, multiple for selecting more than one item from a list.

Radio buttons

Radio buttons are used to define an ‘on’ or ‘off’ option in a list of items.

To define a radio button control we use <input type="radio"> .

Labels are generally added after these radio choices and are defined using <label> These labels should be defined to each input type using the for="" attribute.

To display pre-selected radio buttons we use the checked attribute.

<form>
<label for="radio-buttons">Select Button:</label>
<input checked="checked" name="radio" type="radio" value="one" /><label for="radio-one"> Option 1 </label>
<input name="radio" type="radio" value="two" /><label for="radio-two"> Option 2 </label>
<input name="radio" type="radio" value="three" /><label for="radio-three"> Option 3 </label>
</form>
Result
Select Button:


Checkbox

Checkboxes allow for one or more listed items to be selected. By default these are displayed as square boxes which use checks to indicate a selection.

To define a checkbox the <input type="checkbox"> is used.

Checkboxes can be pre-selected using the checked attribute.

<form>
<label for="checkbox">Pick an option</label>
<input name="checkbox" type="checkbox" value="One" /> <label for="check-one"> Option 1 </label>
<input name="checkbox" type="checkbox" value="Two" /> <label for="check-two"> Option 2 </label>
</form>
Result


Text Area

Text area is expandable text input element. <textarea>  allows the user to add text in a multi-line text input area. The intial size of this area can be defined using row and col attributes. The rows attribute specifies the visible number of lines in a text area and cols specifies the width of a text area.

<form>
<textarea name="message" rows="6" cols="20"> Type your message
</textarea>
</form>
Result

Date

The date input type allows the user to define a specific date, this can display a date picker by default depending on the browser used.

To define a date input we use <input type="date">.

<form>Enter date:
<input name="your_name" type="date" />
</form>
Result
Enter date:

Attaching files

To select files to be uploaded and submitted with a form input type type="file" is used. This creates a default button and text, which appears unstyled in this css. Please note the default look of this button varies between browsers.

<form>
<label>Select a file to upload:</label>
<input name="selectedfile" type="file" />
</form>
Result

Range Input

The <input type="range" allows the user to specify a numeric value typically displayed with a slider or dial control. Default range for a slider is 0 to 100, numbers and steps can be adjusted using min, max and step attribute.

<form>
<label>Select range:</label>
<input name="range" type="range" min="0" max="10" step="1"/>
</form>
Result

Fieldset

To define a group of several related labels and controls we use the  <fieldset> tag. This is used to wraps the group of form elements and must always appears inside the <form> </form>  tags. Form elements inside the <fieldset> element are displayed within a grouped area as shown below.

<form>
<fieldset>
<legend>Please select your preferred contact method:</legend>
<input id="option1" checked="checked" name="contact" type="radio" value="email" /><label for="option1">Email</label>
<input id="option2" name="contact" type="radio" value="phone" /><label for="option2">Phone</label>
<input id="option3" name="contact" type="radio" value="mail" /><label for="option3">Mail</label>
<button type="submit">Submit</button>
</fieldset>
</form>
Result
Please select your preferred contact method:

List of input types (controls)

This list below shows the available input types  <input type="">, for example <input type="button"> which add a clickable button to a form.

button A clickable button
checkbox Checkbox with selected or deselected option
color A control to specify colour
date Control for entering a date
datetime-local Control for entering local date and time
email Field for adding an email address
file Control to let the user select a file
hidden A control to place a hidden value submitted with the form
image A graphical submit button
month Control for entering a month and year
number Control for entering a number
password Text field with characters obscured.
radio Radio buttons for selecting a single value or multiple choices
range Control for entering a number whose exact value is not important
reset Button to reset the form to default values
search Text field for entering search strings
submit Button to submit the form
tel Control for entering a telephone number
text Single line text field. Line breaks are automatically removed
time Control for entering a time value
url Field for entering a URL
week Control for entering week number

Sending forms

Form use action attribute to define where information in the form inputs should be sent once it has been submitted and the method by which the information should be sent.

<form action="/filename.php" method="POST">

For example, in the above code, the information collected from the form will be sent to a PHP document called filename.php using the POST method.

POST and GET are the two method types POST is used for sensitive information and GET is used for none sensitive information.

When using the POST method information in the from can be encyrpted using enctype="value" attribute, the value of encryption can be set application/x-www-form-urlencoded (default), multipart/form-data or text/plain.  Forms with <input type=""> should use multipart/form-data .

<form action="/filename.php" method="POST" enctype="multipart/form-data">

For a more detailed explanation visit Mozilla.org 

 


 

Next step 
HTML – 7 – Divs, Spans, Classes, Ids

5 – HTML – Images

Images

Images have played a large part in making the internet such a popular medium. Images bring plain text pages to life and the use of logos, photographs, graphics, illustrations and icons are part of every website.

How to add an image

To add an image in HTML we use the img element followed by the src source image URL, which can be a relative or an absolute link.  The img element is an empty element, so it does not require a closing tag.

<img src="URL/filename.jpg">
<img src="resources/images/logo.jpg">
<img src="http://demos.points-pixels.com/resources/images/logo.jpg">
Result

For more information on absolute and relative links see the last post.

How to change the size of an HTML image

We control the size of an image by adding height and width attributes to the img element. Sizes for height and width attributes are always pixels.

<img src="resources/images/logo.jpg" width="128" height="128" >
Result

Adding an ALT tag

The alt tag is used to describe an image for screen-readers, it also appears in place of an image if it does not load. alt is also helpful for search engines when cataloguing images and pages.

The alt tag is added as an attribute to an image.

<img src="filename.jpg" alt="add descriptive text about an image" height="128" width="128">

It is important to add descriptive alt tags so that people using screen-readers will be able to understand what the image contains.

Waves breaking on overcast beach
image1234.jpg

For example with the above image, instead of just having a meaningless file name, we should describe what the image looks like. Therefore, it would be better to use “Waves breaking on a cloudy beach” for the alt tag.

Creating thumbnail images

Thumbnail or preview images which link to a larger image in a new window is a technique that is used often within websites and app. To create this effect, we add an <a> anchor link from the smaller image to open a new window that will show the larger image.

<a href=“large-image-url” target=”_blank” src=”thumbnail-url”</a>
Result

Adding a caption to an image 

Adding a caption to an image requires the image to be wrapped in the <figure> element. Inside this is added the image followed by <figcaption> element which includes the caption text.

<figure>
<img src="resources/images/logo.jpg">
<figcaption>This is the caption text</figcaption>
</figure>
Result
This is the caption text

Image formats

Below is a list of the most commonly used formats.

.bmp Bitmap Image Format
.gif Graphics Interchange Format
.jpg Joint Photographic Experts Group
.png Portable Network Graphic
.svg Scaleable Vector Graphic

Each of these formats has strengths and weaknesses, so let’s take a closer look at each type to see which are the most suitable formats for different types of images.

BMP

Bitmap images are created using individual colour values for each pixel in the image. BMP is a lossless format which retains all this image data making the files larger than other formats. As a result, BMP has been surpassed by other formats which can compress the image data into smaller files sizes which require less time to load.

GIF

GIF is bitmapped image format which enables an image to be compressed by limiting the number of colours used in the image.

GIF images contain a maximum 256 colours. Images can be further compressed by reducing the number of colours used in an image. Image creation and editing software like Adobe Photoshop allow for granular control when optimising GIF images, to produce the best quality and performance results.

128 color palette (19kb) vs palette 8 color (6kb) GIF images

Click on the image above to see a range of settings applied to the same image.

Animated GIFs

GIF images have another benefit and that is they can be animated. GIF images can include a series of images, which can be played in sequence to create an animation. GIF animations are used extensively online especially in social media as eye-catching and easily shareable content.

 JPEG

The JPEG format was developed specifically to compress photo-realistic images which can have millions of colours.

JPEG image compression has 12 settings ranging from low to high quality. The higher the setting, the larger the file size and the longer the image will take to load. The image compression choice is a balance between quality and reduced file size (quicker loading times).

Maximum quality (58kb) vs low quality (22kb) JPEG image

Click on the image above to more compression settings on the same image.

You may find it surprising to know how much file space is saved using the high-quality image setting vs maximum quality image setting with almost no visible difference in the images.

PNG

PNG is a lossless format with file compression along with support for transparency. File compression occurs by rearranging the data in an image into a more efficient data structure which requires less information allowing the file size to become smaller.

So why don’t we just use PNG files all the time? Well, even though PNG files can be compressed they are still lossless and that means they still retain all the information in the image, this can lead to larger file sizes compared to compressed JPEGs which loses information when compressed.

Images compressed with PNG format work best for graphics, images with text and images with transparent backgrounds.

Screenshot image of mobile phone with points and pixels logo

SVG

SVG is a scalable vector format, this means the image can be scaled to any size. Unlink  JPG, PNG, GIF which are bitmapped images, SVG images contain a series of coded instruction which recreates the image using coordinates, lines, shapes and colours.

SVG images are easy to animate as every vector element and attribute can be changed directly in the code. This makes it possible to create animated sequences without creating new images for each animated frame.

So, which the best format?

This all depends on the individual image but as a general guide the following can be applied:

JPEG is generally the best choice for creating smaller files sizes on photographic images with the least noticeable loss of quality.

PNG is generally the best choice for images with text and graphics and also for images with transparent backgrounds.

SVG is generally the best choice for anything that is vector based such as logos, icons and illustrations.

Important: Images should always be optimised to have faster loading times, so as to ensure the users experience is not deteriorated by slow loading images.


 

Next step 
HTML – 6 – Forms

 

4 – HTML – Links

Links

The internet is a mass of information and data distributed around the world in a web of interconnecting pages.

To access these pages we can simply type a URL address into our favourite internet browser (Chrome, Firefox, Safari, etc).

Typing a different URL address every time we wanted to navigate to another source of information would be slow and frustrating (imagine all those typing errors), so we can thank hyperlinks (links) for making access to the internet easier for us all.

HTML Hyperlinks (links) enable users to navigate to internal or external web content, information and resources by clicking or tapping on a hyperlinked text, image or graphic.

Internal links (relative links) are hyperlinks that connect users to other pages and resources within the same domain name.

External links (absolute links) are hyperlinks to websites, apps or resources which can be located anywhere on the internet.

How to write <a> link

All hyperlinks elements use the <a> tag or anchor tag. A href attribute is added to the opening <a> tag with the hyperlink address, so the opening tag becomes <a href ="url">. The link text is added next, this is the clickable text link the user will see. The closing anchor tag </a> finishes the element.

<a href="url">link text</a>

External links

Hyperlinks to external resources and information must use the absolute URL address as they are connecting to files outside the current domain.

<a href="https://www.twitter.com/points_pixels">Follow us on twitter</a>

The above link opens the new content in the same browser window.

To create a hyperlink that opens in a new browser window or tab, we need to add a target attribute with its value set to blank, this is added after the URL. When this type of link is clicked, it will open a new blank page where the linked content will be displayed.

<a href="https://twitter.com/points_pixels" target="_blank">Follow us on twitter</a>

Internal links

Internal links (relative path links) do not require the full URL address. To illustrate this, both the following links point to the same file, the first is an absolute link, the second is a relative link.

<a href="http://www.points-pixels.com/contact.html">Contact us</a>
Result
<a href="contact.html">Contact us</a>
Result

This first link above is called an absolute link as it contains the full URL address and can be accessed from anywhere online.

The second link, is a relative link which locates the linked content by following a relative path from its current location to the linked content.

Internal links and navigating folders

The internal hyperlink (above) locates a target file at the same folder level as the current page and does not require http://www..

If a target file is not located in the same folder the link address needs to include the folder structure to target the correct file. To do this we use / and the folder name.

<a href="html/contact.html">Contact us</a>

The link above targets the contact.html page in the html folder in the same domain. This link connects to file in a folder that is located one level below the current file.

<a href="../html/contact.html">Contact us</a>

To link to a file in a folder above the current level we need to use  ../  to navigate to the higher level. Repeating these symbols takes you to higher levels, so to get two levels higher we use ../../ .

Relative links still work even if a website domain is changed, this can make them particularly useful for developing websites as it allows files to be transferred from local or staging environments without having to change all URL addresses of the linked content.

Bookmark links

Bookmark links allow users to quickly navigate (jump) to content within a page. When the user clicks on a bookmark link the browser scrolls to a specified target area on the page.

For a bookmark link to work an area of the website needs to be identified as the target for the link. To achieve this an id="" attribute is added to a target element. The link  <a href="">  URL address needs to include a # hashtag (number/pound sign), which represent an id, followed by the id name. Now when the bookmark link is clicked the content will scroll to the position of the id attribute.

<h2 id="jump-link"> This headline has an ID link</h2>
<a href="#jump-link">Link to content</a>

Image links

Image links can be photographs, logos, icons or graphic images. To create an image a link image source <img src=""> is added after the opening anchor tag <a href=""> and before the closing </a>. This replace where the link text would appear in a text hyperlink. Inside the  <img src="">  image quotations, we add the link path for the image and the image file name.

<a href="http://www.points-pixels.com">
<img src="http://www.points-pixels.com/images/logo.jpg"
</a>
Result

Email links

Email links include the mailto: followed by the email address.

<a href="mailto:hello@points-pixels.com">Email me</a>
Result

Mail links can also be formatted to include subject title, body text and add CC and BCC recipients using the attributes listed below:

mailto: recipient email
&cc= adds CC recipients
&bcc= adds BCC recipient(s)
&subject= to set the email subject
&body= to set the body of the message

Below is an example of a more advanced mailto: link using options from the table above. Important the ? is needed to add addtional mail fields. The %20 is used to define a space in the text.

<a href="mailto:hello@points-pixels.com?&cc=one@points-pixels.com,
two@points-pixels.com, three@points-pixels.com&bcc=last@points-pixels.com&subject=Email%20with%20cc%20bcc%20subject%20and%20body%20message&body=Body%20message">Email Us</a>
Result

Download links

To create a download link downloadis added to the end of this opening anchor tag, just after the URL.

<a href="http://www.domain.com/filename.pdf" download>Click to Download</a>

 


 

Next step 
HTML – 5 – Images

 

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

3 – HTML – Tables

Table basics

A table is data (text and numbers) arranged in rows and columns.

All tables are defined by the <table> tag.

<table>
<!-- table data goes here-->
</table>

In HTML tables are defined by rows which are stacked on top of each other. Table data is added left to right forming the columns.

Simple tables

A simple table can be created by defining each <tr> table row and then adding <td> table data for each cell. The first <td> table data will add a value in first column (left) and the last <td>table data will be added to the last column (right), each table row is closed using the </tr> table row closing  tag.

<table>
<tr>
<td>Table data 1</td>
<td>Table data 2</td>
</tr>
<tr>
<td>Table data 3</td>
<td>Table data 4</td>
</tr>
</table>
Result
Table data 1 Table data 2
Table data 3 Table data 4

Table headers

Table header <th> defines a cell as header item.

Table headers are generally placed on the top row and side columns, but can be placed in any of the table cells.

<table>
<tr>
<th>Table header 1</th>
<th>Table header 2</th>
<th>Table header 3</th>
</tr>
<tr>
<td>Table data 1</td>
<td>Table data 2</td>
<td>Table data 3</td>
</tr>
<tr>
<td>Table data 4</td>
<td>Table data 5</td>
<td>Table data 6</td>
</tr>
</table>
Result
Table header 1 Table header 2 Table header 3
Table data 1 Table data 2 Table data 3
Table data 4 Table data 5 Table data 6

Table header, body and footer

Three areas of the table can be defined, table header <thead>, table body <tbody> and table footer <tfoot>.

Defining the table areas enables the browser to scroll the body of a table independently from the tables header and footer, which especially useful when tables have many rows of data.

<thead> defines the table header
<tbody> defines the table body
<tfoot> defines the table footer
<table>
<thead>
<tr>
<th>Table header 1</th>
<th>Table header 2</th>
<th>Table header 3</th>
</tr>
</thead>
<tbody>
<tr>
<tr>
<td>Table data 1</td>
<td>Table data 2</td>
<td>Table data 3</td>
</tr>
<tr>
<td>Table data 4</td>
<td>Table data 5</td>
<td>Table data 6</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Footer</td>
</tr>
</foot>
</table>
Result
Table header 1 Table header 2 Table header 3
Table data 1 Table data 2 Table data 3
Table data 4 Table data 5 Table data 6
Footer

Colspan and Rowspan

Column span <colspan> expands cells across multiple columns.

<table>
<thead>
<tr>
<th>Table header 1</th>
<th>Table header 2</th>
<th>Table header 3</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">This cell now spans 2 columns</td>
<td>Column 2</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
</tr>
</tbody>
</table>
Result
Table header 1 Table header 2 Table header 3
This cell now spans 2 columns Column 2
Column 1 Column 2 Column 3


Row span <rowspan> expands cells across multiple rows.

<table>
<thead>
<tr>
<th>Table header 1</th>
<th>Table header 2</th>
<th>Table header 3</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2">This cell spans 2 rows</td>
<td>Column 2</td>
<td>Column 3</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
</tbody>
</table>
Result
Table header 1 Table header 2 Table header 3
This cell spans 2 rows Column 2 Column 3
Column 1 Column 2

Table captions

The table <caption> specifies the title or caption for the table and, if used, should be the first item added after the table tag.

<table>
<caption>This is the table caption</caption>
<thead>
<tr>
<th>Table header 1</th>
<th>Table header 2</th>
</tr>
</thead>
<tbody>
<tr>
<tr>
<td>Table data 1</td>
<td>Table data 2</td>
</tr>
<tr>
<td>Table data 4</td>
<td>Table data 5</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2"Footer</td>
</tr>
</foot>
</table>
Result
This is the table caption
Table header 1 Table header 2
Table data 1 Table data 2
Table data 4 Table data 5
Footer

 


 

Next step 
HTML – 4 – Links

 

2 – HTML – Text Elements

Text, the most common element in an HTML document, can be styled to make it visually appealing, improve legibility and be easier to read.

Paragraph styles

The <p>  tag is used to indicate the beginning of a text paragraph and is the </p> tag is used at the end of the paragraph. Text for the paragraph is placed between these tags.

<p>This is a paragraph of text.</p>
Result

This is a paragraph of text.

Line breaks

Text lines can be manually split using the <br> line break tag. The line break requires no closing tag.

<p>This is a paragraph with a manual line break <br>the rest of the text appears on the next line.</p>
Result

This is a paragraph with a manual line break
the rest of the text appears on the next line.

Bold, Italic and Bold Italic

Paragraph text can be styled using bold <b> or <strong>, italic <i> or <em> and bold italic <strong><em> or <b><i> styles.

<p>This is a paragraph of text with <em>italic</em>,<strong> bold</strong> and<strong><em> bold italic</em></strong> texts.</p>
Result

This is a paragraph of text with italic, bold and bold italic texts.

Paragraph formatting styles

This list show formatting that can be applied to paragraph texts:

<b> Styles text as bold
<strong> Important text (bold)
<i> Styles text as italic
<em> Emphasized text (italic)
<small> Small text
<mark> Marked texts
<del> Deleted text
<ins> Inserted text
<sub> Subscript
<sup> Superscript

 


Headers

Headlines are defined using the <h1-6> header tags. These tags define the hierarchy of each headline within a document, <h1> headlines being the most important and <h6> being the least important.

<h1>H1 Header</h1>
<h2>H2 Header</h2>
<h3>H3 Header</h3>
<h4>H4 Header</h4>
<h5>H5 Header</h5>
<h6>H6 Header</h6>
Result
Header H1
Header H2
Header H3
Header H4
Header H5
Header H6

Header markup allows assistive technologies, such as search engines, to define the importance of each headline based on its tag. The <h1> headline will always be classified as more important than a headline with an <h2> tag and <h2> tagged headline will always be more important than <h3> headline, etc.

Headlines can be defined using any font, size, weight or color but as a general rule, they should follow the visual hierarchy of h1-h6.

 


Text areas

These tags are used to define an area of written content with a specific attribute, often these have styling applied to them.

<abbr> Defines an abbreviation or acronym
<address> Defines the contact information of an author
<blockquote> Defines a section that is quoted from another source
<cite> Defines the title of the work
<pre> Defines an area of preformatted text
<q> Defines a short inline quotation

 


Lists

The two most common types of lists are unordered lists and ordered lists.

Unordered lists display each list item using a marker (by default a bullet list).

Ordered lists display each item listed either numerical (1, 2, 3, 4…), alphabetical (A, B, C, D…) or by using Roman numerals (i, ii, iii, iv…).

Both these list types are is defined firstly by the list type either unordered list <ul> or ordered list <ol> and then followed by the list items <li>.

Unordered list

<ul>
<li> List item 1 </li>
<li> List item 2 </li>
<li> List item 3 </li>
</ul>
Result
  • List item 1
  • List item 2
  • List item 3

Ordered list

<ol>
<li> List item 1 </li>
<li> List item 2 </li>
<li> List item 3 </li>
</ol>
Result
  1. List item 1
  2. List item 2
  3. List item 3

Order list types

Ordered lists can be displayed using numbers, letters or roman numerals. The starting value for a list can be defined as well as the order in which the list items are ordered.

<ol start=”value”> Starts list from a specified value
<ol reversed> Reverses the list order
<ol type=”1″> List with numbers (default)
<ol type=”A”> List with capital letters
<ol type=”a”> List with lowercase letters
<ol type=”I”> List with capital roman numerals
<ol type=”i”> List with lowercase roman numerals

Description list (definition list)

Description lists is another list type which is used specifically to define a list of items where each item has a description. For example in a glossary where a term is followed by a description of the term.

To define this list type we use Description List <dl> </dl> , nested in which we use the Description Term  <dt>  to define the title of the term, followed by Description Data <dd>  to define the description data for the term.

<dl>
<dt>Item 1</dt>
<dd>Description for item 1</dd>
<dt>Item 2</dt>
<dd>Description for item 1</dd>
</dl>
Result
Item 1
Description for item 1
Item 2
Description for item 1

 


 

Next step 
HTML – 3 – Tables

 

1 – HTML – Basic setup and structure

HTML markup

Writing HTML markup requires an understanding of how to define an HTML element using tags and attributes as well as the concept of nesting.

HTML Tags

Tags are used to define the start and end of an element.

Open and closed  < > angle brackets are used to enclose the tag name.

<tagname> 

Optionally, attributes can be placed after the tag name. More than one attribute may be added by placing a space between each attribute.

<tagname attribute="value" attribute="value">

This tag is known as an opening tag. At the end of an element is placed a closing tag which adds / before the closing tag name.

<tagname>content</tagname>

Examples of HTML elements:

<h1>This is a H1 headline</h1>
<p>This is a paragraph of text</p>

Void elements

A few HTML elements don’t require closing tags, these are called void elements  and instead can be written only with the <tagname> or by using  <tagname />  (space, forward slash after the tag name).

Examples of void elements:

<hr> or <hr /> this creates a horizontal rule.
<br> or <br /> this adds a single line break in a paragraph.

Nesting

Every HTML document contains nested elements.

Nesting places one HTML element inside another. The outer element will always have an influence on the inner element and therefore it’s important to understand this concept when writing HTML.

For example, if we have three HTML boxes nested inside each other and we change the color of the outer box to red, it will change the color of the two inner boxes also to red. If we then change the most inner box to blue, only this box will change color leaving the two outer boxes red.

It is important to make sure each element is nested correctly and to remember to close tags in the reverse order of opening them.

 


Setting up an HTML document

HTML 5 (Hypertext Markup Language) requires the following code as a basic foundation to which all other elements are added.

<!DOCTYPE html>
<html>
<head>
<!– This is the head area –>
</head>
<body>
<!– This is body area –>
</body>
</html>

Document Type (DOCTYPE)

<!DOCTYPE html>

<!DOCTYPE html> tells the web browser to render the file as an HTML 5 document and should be placed at the begining of the document.

<!DOCTYPE html> defines the type of HTML language being used – HTML5 standards mode. HTML code prior to Oct 2014, uses different declarations.  

HTML

<html>
<!-- HTML is added between the opening and closing HTML tags -->
</html>

The <html> tag defines where the HTML code is placed in the document. The HTML is placed between the opening <html> and closing </html> tags.

Head

<head>
<!-- The head includes the title, links, scripts and more -->

</head>

The <head>  is a container for the information that is included in the HTML document such as title, scripts, meta information. The <head> container is always positioned at the top of the <body> container, just like the head of a person is always positioned on top of their body.

Body

<body>
<p>This a paragraph of text</p>

</body>

The <body> is where all content is placed that is to be displayed in the web browser. The head is always attached below the body.

 


What’s in the <head>?

Next, let’s start looking at what type of information that can be placed inside the <head> of an HTML document.

<!DOCTYPE html>
<html>
<head>
<base href=”http://www.points-pixels.com”>
<meta charset=”utf-8″>
<title>This is the title of the page</title>
<link rel=”stylesheet” href=”styles.css”>
<script src=”script.js”></script>
</head>
<body>
<!– This were the content goes –>
</body>
</html>

Titles

<title>This is the title of the page</title>

The <title> tag defines the title of the HTML document in the web browser. It is also used as the title of the page in the search result (Google, etc) and is the title of any bookmarked page.

The <title>tag is required in all HTML files.

Style

<!DOCTYPE html>
<html>
<head>
<style>
h1 {color:red;}
p {color:gray;}
</style>
</head>
<body>
<h1> This headline will be red </h1>
<p> This text will be gray </p>
</html>
</body>

The <style> tag is used to identify styling information for the elements found in the <body>. The style elements are usually placed in an external style sheet CSS (Cascading Style Sheets) and linked to the HTML document using a <link> in the <head> tag.

Links

<link rel="stylesheet" type="text/css" href="styles.css">
<link 
href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"
>

The <link> tag is used to link an external document or resource. The link tag is commonly used to link external style sheets and web fonts.

Meta

<meta charset="UTF-8">
<meta name="description" content="Designer learning to code">
<meta name="keywords"content="Keyword, Keyword, Keyword">
<meta name="author" content="Points-Pixels">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

The <meta> tag is used to define information in the HTML document such as display language, the content used by search engines and the author of the document. Meta information is not visible in the browser.

HTML 5 allows the <meta> tag to be used to define the viewport (the visible screen area), allowing for more control on how information is displayed on different sized devices.

Scripts

<script src="script.js"></script>
<noscript>
Your browser does not support JavaScript!</noscript>

The <script> tag is used define a client-side script (JavaScript). The script can be an external link (as shown) or included in between the script tags. <noscript> tag is used to define alternative content for users who have disabled scripts from running in their web browser.

Scripts can also be used in the <body> of a document.

Base

<!DOCTYPE html>
<head>
<base href="http://www.points-pixels.com/images/">
</head>

<body>
<img src="image.jpg" alt="an image from the images folder">
</body>

The <base> tag defines the base URL/target in the HTML document for all relative URLs, such as which folder stores all the images.

Only one <base> element is allowed per document.

<head>

HTML5 does not require the <head> tag . In HTML 5, the information for the header can be placed directly after the <html> tag and before the <body> tag.

!DOCTYPE html
<html>
<title>This is the title of the page</title>
<!-- This were the content goes -->
<body>
<!-- This were the content goes -->
</body>
</html>

 


Saving HTML files

HTML files can be saved with the .html or .htm file extensions.

index.html is the most common name for the landing page (homepage) as most servers will look for the default file called index.html or index.htm first. Servers can be configured to use different default names if needed.

 


 

Next step
HTML – 2 – Text Elements

 

Learning HTML in 30 days

So let the fun begin…

Let’s get started…

HTML is relatively straightforward language to learn and 30 days (1-2 hours per day) should be enough time to build a solid knowledge base. It is possible to learn this in less time, but due to family and work commitments, I only have a couple of hours available per day.

Text Editor

I am going to use Atom, a free open source text editor developed by GitHub. I have used this a little before and find it simple and intuitive, so I will stick with what works for me. Here is a list of some other popular free text editors.

Reference

I used a number of references to help write this guide, these can be found along with other useful links on the resources page.

Demos 

At this stage, I don’t have a platform for adding demo code files, hopefully, these will be added later.

 


 

These are the subjects I will learn:  

HTML Basic setup and structure

<!DOCTYPE html>
<html>
<!-- Add you HTML code here -->
</html>

Text

<p>This is paragraph</p>

Tables

<table>
<tr>
<th>First</th>
<th>Second</th>
</tr>
<tr>
<td>One</td>
<td>Two</td>
</tr>
</table>

Links

<a href="http://points-pixels.com">Visit our Website</a> 

Images

<img src="picture.jpg" alt="picture description">

Forms

<form>
<label>Name:</label>  
<input type="text" name=“name"> 
</form>

Divs, Spans, Classes and Ids

<div>This is div and a<span> inline span</span></div>
<div>
<h1 id="id-name">I am a unique ID headline</h1>
<h1 class="class-name">I am a Class headline</h1>
</div>

Styles

<p style="color:red; font-size:72px;"> This some big red text</p>

Semantics

<article>
<h1>This is an Article</h1>

<p>Its is very short</p>
</article>

 


 

Next step
HTML – 1 – Basic setup and structure

 

Humble Beginnings

Making a start…

I have no master plan and don’t want to set any limits, but I do have a general idea of the first steps I want to take.

As a freelance designer, I design almost every day. Having a few years experience I can confidently take project briefs, generate design concepts, incorporate feedback and deliver final designs to hand-off for production, but I am always frustrated by not being able to translate my designs in code.

My experience includes designing websites, portals and apps. I have launched a number of WordPress websites for clients using customisable themes. During this time, I have gained some basic knowledge of HTML and CSS but I find myself compromising my design to my limited coding ability.

Therefore my first goal is to be able to code what I design. I am not looking for a fully functioning website or app, but a true visual representation of what I design. I want to be confident that the code I create and handover to developers is of a professional standard.

Where to begin

Before learning something new it’s important to understand what you already know, what you need to know and then plan a path to reach your goal by filling in all the missing skills/knowledge areas along the way.

Inspired by the Feynman technique, I want to learn the subject in depth, so as to be able to explain it in plain language to another person who has little knowledge of the subject.

I learned very early the difference between knowing the name of something and knowing something.

Richard Feyman

Basic approach
  1. Identify the subject and write down everything you know about it. Define the gaps in your knowledge into subject areas and list them.
  2. Deconstruct each subject area into simple tasks, that can be learned quickly. You can use the 80/20 principle to define which are the most important or commonly used tasks you need to learn.
  3. Learn the subject well enough to be able to self-correct and/or to explain it in simple terms to a friend or colleague.
  4. Review and correct, before moving on to the next task.

 


 

OK, let start with what I think I know… 

Design process

  1. Everything starts with a briefing document, project outline or design specification in order to define the deliverables and goals.
  2. Research for the project, understanding needs and requirements.
  3. Create wireframes (low fidelity design) to quickly test concepts.
  4. Visual design (high fidelity design and mockups), creating the visual style and language for a website, app or product.
  5. Design prototypes (basic demos including some clickable functionality, page transitions, etc) to test interaction and key flows.
  6. Approved wireframes, visual designs, style guide and prototypes are then handed over to a front-end designer/developer to code.

Going a bit further each of these areas has certain tasks.

Tasks

Understanding, I will make broad strokes here as every project varies based on the information you receive and the involvement required for the project. Understanding defines what is possible and which solution will potentially produce the best results based on what the customer (user) wants or needs, the clients’ goals, available technology and budget. Tasks can include customers and stakeholders interviews, user product testing, market research and mood boards and other tasks that can offer potential insight into a project.

Wireframes are used to quickly create designs to show how a website, app or products will look and function at a basic level. These are used to explore how users engage with the design in order to perform a series of tasks or follow a customers journey. The wireframes can be simple hand-drawn sketches, keyline drawings or even clickable demos. These are reviewed and tested before passing on to either a visual designer, front designer/developer.

Visual design is the creation of high fidelity design, generally using design applications such as Sketch, Adobe CC. Visual design, developed from the wireframes, creates the look and feel of a website, app or product. The visual design will define layout, colours, typography, images, graphics and icon style used in the final product. These choices will often be influenced by a companies/organisations branding and marketing communications. Once the visual design is approved, completed screen/page designs and design assets (logos, image and icons) are passed on to the front-end designer/developer. The visual designer may produce a style guide of key design elements and components to be used as a reference in any future design developments.

Front End design/development is the translation of the design into the code used in the final website, app or products.

Roles

UX or UXD (User Experience) designer is focused on the processes found in a website, app or product and how they engage with the user. They are interested in finding the most convenient and practical way for the user to perform a task while providing a pleasurable interaction between them and the product/service they are using.

UI (User Interface) designers create the visual design of a web page, app or product. The UI designer role is to develop a visual design language which enhances the UX design. They create an aesthetic to match both the required functionality and also align this with the brand values of the company/organisation and to make this appealing to the user.

UI/UX designer is comfortable in both of these roles.

Front-End designer/developer takes the finalised visual design and recreates them into the workable front-end code of a website or web apps using HTML, CSS and Javascript.

You could simplify the roles as follows; the UX designer is interested in how people interact with a product, the UI designer is interested in making the product as unique and attractive to people as possible and Front-End designer is interested in using logic and reason to ensure the product functions.


 

And now what I don’t know…

I have split this list into two areas one is code related the other is design software related.

Code

This is the area I will focus most of my time as it’s the one I know least about.

  • I don’t know enough HTML/CSS to recreate my design in code.
  • I don’t know anything about JavaScript and I will need to know how to be able to write JavaScript or use a JavaScript framework to deliver Front-End design.
  • I don’t know about CSS frameworks, and if I should learn a framework, which framework should I choose (Bootstrap/Foundation, etc).
  • Should a Front-End designer/developer know other languages and if so which languages?

Design

Even though I use a number of design applications, I will look to add some new applications to improve my workflow.

  • I use Sketch but I need to improve my knowledge to be more comfortable using it.
  • I need to explore the latest design tools such as Invision Studio, Figma and Adobe Experience design and test these to see which is I should be investing my time learning.
  • I have limited experience of design prototyping tools and need to find a solution that fits into my workflow.

 


 

Next step  
Learning HTML in 4 weeks