Basic guide to html

What is HTML?

HTML at a glance

  • HTML stands for Hyper Text Markup Language
  • An HTML file is a text file containing markup tags e.g. <B> <TABLE>
  • The markup tags tell the Web browser how to display the page
  • An HTML file must have an htm or html file extension
  • An HTML file can be created using any simple text editor

HTML is the standard formatting language for creating web pages and formatting text online. It gives your browser instructions on what font to use, the colours, position, images and links.

This page is written in HTML. What you are currently viewing is however the end result of the browser reading HTML and rendering it.

In this guide you'll find a brief overview of the structure and examples for everyday formatting, for example within survey pages.

 

 

 

 

 

HTML Tags

What are tags?

  • HTML tags are used to mark-up HTML elements
  • HTML tags are surrounded by the two characters < and >
  • The surrounding characters are called angle brackets
  • HTML tags normally come in pairs like <b> and </b>
  • The first tag in a pair is the start tag, the second tag is the end tag
  • The text between the start and end tags is the element content
  • HTML tags are not case sensitive, <b> means the same as <B> but you should always use lower cases as XHTML (the next HTML generation) is case sensitive

All text in an HTML file is displayed with the exception of text enclosed in angle brackets, < >, known as tags. These tags are used to give formatting instructions to the browser.

A simple example is the bold tag.

in html we write

This next word will be <b>bold</b>

 

which is rendered

This next word will be bold

 

 

 

 

Basic Text Tags

in html we write

this next word is <b>bold</b>, this next word is <i>italic</i>, this next word is <u>underlined</u>.

Which is rendered

this next word is bold this next word is italic this next word is underlined

 

Note how all the text runs together, even though we put the text on separate lines. HTML sees all white space the same and renders it as a single space.

Below are some examples of putting line breaks

 

Line Breaks and Paragraphs

The simplest way to put text on another line is using the line break tag <BR>

in html we write..

This sentence will appear on the first line<br>but this will appear on the second

 

Which is rendered

This sentence will appear on the first line
but this will appear on the second

 

you can also group text using the paragraph tag <P>

<p>This is an initial paragraph, note all the text is bunched together</p>This is the second paragraph which will be separate.</p>

 

Which is rendered

This is an initial paragraph, note all the text is bunched together

This is the second paragraph which will be separate

 

 

Font and Size

There are 3 major font families available online. these are Courier, Times and Arial. All other font faces cannot be relied on to display correctly because the need to be installed on the end-users machine.

To display a font you need to use a 'span' tag to mark out the text you want to format and specify the font-family as below.

<span style='font-family:courier'>Courier</span>, <span style='font-family:Times'>Times</span><span style='font-family:Arial'>Times</span>

 

Font size works in a similar way

<span style='font-size:20pt'>This is 20 pt text</span><br>

<span style='font-size:15pt'>This is 15 pt text</span><br>

<span style='font-size:10pt'>This is 10 pt text</span><br>

<span style='font-size:5pt'>This is 5 pt text</span><br>

rendered as
This is 20 pt text
This is 15 pt text
This is 10 pt text
This is 5 pt text

 

Colour

Colour may be applied to text and background.

for example

<span style='color:red'>This is red</span><br>

<span style='color:green'>This is green</span><br>

<span style='color:blue'>This is blue</span><br>

rendered as
This is red
This is green
This is blue

 

Colour, font and size may also be combined

for example

<span style='color:red;font-size:20pt;font-family:courier'>This is a large red courier font</span>

rendered as
This is a large red courier font

For specific colours, you will need to specify the hexcode , e.g. instead of red, we use #ff0000. Hex code colours are beyond the scope of this guide.

Headings

Headings are defined by the H1, H2 to H6 tags.

<h1>This is a level 1 heading</h1>

<h2>This is a level 2 heading</h2>

<h3>This is a level 3 heading</h3>

<h4>This is a level 4 heading</h4>

<h5>This is a level 5 heading</h5>

<h6>This is a level 6 heading</h6>

Which is rendered

This is a level 1 heading

This is a level 2 heading

This is a level 3 heading

This is a level 4 heading

This is a level 5 heading
This is a level 6 heading

Hyperlinks

One of the revolutions of the web is linking pages together. In order to do this you use the anchor tag <A> and </A>. The text between the tags will become an active link.

If for example we want to link to Wikipedia, which is http://www.wikipedia.com

for example

The last word will in this sentence will be a link to <a href='http://www.wikipedia.com'>
wikipedia
</a>

rendered as
The last word will in this sentence will be a link to wikipedia

 

Lists

There exist 2 main types of lists: ordered (with numbers) and unordered (with simple bullets).

the code for an ordered list is below.

<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>

rendered as
  1. Item 1
  2. Item 2
  3. Item 3

 

the code for an un ordered (bulleted) list is below.

<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>

rendered as
  • Item 1
  • Item 2
  • Item 3

Images

In order to use images, you need to upload them first on to a server. On this server we have an image which is at web location http://surveyengine.com/images/star.gif

the code for an un ordered (bulleted) list is below.

<img src="http://surveyengine.com/images/star.gif"/>

rendered as
star

 

  • Each HTML element has an element name (body, h1, p, br)
  • The start tag is the name surrounded by angle brackets: <b>
  • The end tag is a slash and the name surrounded by angle brackets </b>
  • The element content occurs between the start tag and the end tag
  • Some HTML elements have no end tag (line break)

 

Useful Tips

When you write HTML text, you can never be sure how the text is displayed in another browser. Some people have large computer displays, some have small. The text will be reformatted every time the user resizes his window. Never try to format the text in your editor by adding empty lines and spaces to the text.
HTML will truncate the spaces in your text. Any number of spaces count as one. Some extra information: In HTML a new line counts as one space. 
Using empty paragraphs <p> to insert blank lines is a bad habit. Use the <br> tag instead. (But don't use the <br> tag to create lists. Wait until you have learned about HTML lists.)
HTML automatically adds an extra blank line before and after some elements, like before and after a paragraph, and before and after a heading.
We use a horizontal rule (the <hr> tag), to separate the sections in our tutorials.

Further Reading

For a good all round tutorial visit http://w3schools.com/