Académique Documents
Professionnel Documents
Culture Documents
By Kevin Muldoon
Copyright
All rights reserved. No part of this book can be reproduced, copied,
stored in a retrieval system or transmitted over the web without prior
approval of BloggingTips.com. Brief quotations embedded in reviews
are permitted.
However, should you want to develop your HTML skills further after
reading this e-book, I encourage you to check out the further reading
section at the end of the book for links to advanced HTML Tutorials.
Also, please note that this book was written in UK English. Therefore,
those who are used to American English may notice some slight
differences in spelling like colour instead of color and emphasise
instead of emphasize.
Acknowledgements
Last but not least, I would like to thank the following people who have
helped me release this e-book:
• The Blogging Tips Writing Team. If they were not writing great
articles for the blog everyday, I wouldn’t have had the time to
write this e-book!
• The Blogging Tips readers!! Yes I know, it’s cheesy; but seriously,
I wouldn’t have had the passion or drive to write this e-book in the
first place if it wasn’t for the great feedback from you all.
TAGS ................................................................................ 13
ELEMENTS .......................................................................... 15
ATTRIBUTES ........................................................................ 17
NESTING TAGS ..................................................................... 17
CHAPTER 3: THE BASIC STRUCTURE OF AN HTML PAGE.................... 19
The language was refined during the 1990’s. The rules for HTML 2.0
were published in 1995, for 3.2 in early in 1997 and for 4.0 later that
same year. HTML 4.01 is the most up to date version of the language
though there has been some slight changes since 1997, though nothing
that is worth mentioning in this book.
In the early days of the web most internet users browsed the web with
either Netscape Navigator or Internet Explorer. Unfortunately, the
developers behind these browsers had different ideas on how to
progress the language which resulted in some new tags working in
Netscape Navigator and not on Internet Explorer (and vice versa). As a
result, many web pages looked fine in one browser but completely
messed up on another.
UNIX and Linux based systems did not have this 3 character file
extension limit therefore were able to use .html.
HTML Editors
You can edit an HTML document in just about any editor. Most of my
first websites were coded directly in notepad however I soon realised
the limitations with using such basic editors.
Thankfully most HTML editors are free! For the last 8 years I have
used TextPad to code and edit my websites though there are some great
alternatives available like NotePad++, First Page, CoffeeCup and
PageBreeze. There are literally hundreds of free HTML editors
available so I recommend trying a few out until you find one which suits
you.
In the background the editor converts everything you type into HTML.
Most WYSIWYG editors allow you to view your blog post visually or
see the raw HTML code.
If you have been using the WYSIWYG editor to write your posts and a
pre made template for your blog design, then you may not have had too
much exposure to the HTML language.
Therefore I encourage you all to view the source of your own blog to
see the code which drives your website. In most browsers the ‘View
Source’ link is in the tools section of your browser menu.
No doubt the source code your blog generates looks foreign to you but
don’t worry, you will soon see how it all breaks down and realise that
HTML isn’t a difficult language to learn ☺
If you have been blogging for a while and have a basic understanding of
HTML already, feel free to skip this chapter and refer to it at a later
date.
Tags
In HTML you control text and information
by wrapping tags around them. Tags begin
with a less than symbol (<) and end with a
more than symbol (>) i.e. <tagname>.
I will illustrate this with an example. In this example I have used the
strong tag (<strong>), which changes the text font to bold; the
emphasise tag (<em>), which changes the text font to italic; and the
paragraph tag<p>, which aligns and spaces the content with the
surrounding area.
Code Example:
<p>I like to <em>emphasise</em> some words and
<strong>strongly emphasise</strong> others.</p>
Output:
I like to emphasise some words and strongly emphasise others.
If any of the tags were not properly closed, the output would not be
correct. In the example below the emphasise tag was not closed
therefore any text displayed after the opening <em> tag will be
displayed in italic (in most browsers).
Code Example:
<p>I like to <em>emphasise some words and
<strong>strongly emphasise</strong> others.</p>
Output:
I like to emphasise some words and strongly emphasise others.
There are several HTML tags which do not need to be closed. These
are known as Empty Tags and do not need to be closed as they are not
used to wrap around and control any content.
The most common ones used are the Break Line tag (<br>) and the
• The Break Line tag (<br>) ensures that any text/content which
follows is started on the next line.
Elements
In HTML, an element refers to a section of your page and includes the
opening tag, the content which is being marked-up and the closing tag.
* Note, technically you could write a valid HTML page with just the
<html> tag however it would have no title and no content, two things which
are essential to any webpage!!
• The <head> element: The <head> tag comes directly after the
<html> tag and before the <body> tag. The tags used within
this element are not displayed on your webpage. This element is
used to explain to the browser what should happen before the
page is loaded including meta description (meta tags etc), pre
loading images, specifying the web page title, linking to the
websites CSS stylesheet and much more.
Attributes
Attributes are placed within tags and give
you more control over how your content is
displayed. It allows you to align images,
change the colour of fonts, set the width of a
table and much more.
Many tags also have default attributes which are used if no attributes are
set.
Nesting Tags
HTML is a structured language and allows the use of multiple tags in
order to control content. These tags have to be nested or the output
will be a little messed up.
Notice how <tag3> is closed first since it was the last tag opened, then
<tag1> is closed, and finally <tag2> (the opening tag).
In the example below I have made the link to BloggingTips bold and
italic. Notice how each tag is closed in the correct order.
Code Example:
<a href=”http://www.bloggingtips.com”>
<strong><em>BloggingTips</em></strong></a>
Output:
BloggingTips
So let’s move on and create your first every HTML page! Here is what
you need to do:
• Copy the code below into the document and save it somewhere
on your computer as test.html (note: the .html file extension
converts the document into an HTML file).
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<title>My very first web page!</title>
‘Basic HTML: An Introduction to HTML for bloggers’
By Kevin Muldoon
</head>
<body>
<h1>Welcome to my very first web page</h1>
<p>Wow – HTML is so easy!!<p>
</body>
</html>
You should now see something like this via your browser:
I encourage you all to play around with the test.html web page for a
while. Change things up a little using some of the tags you have already
learned and try not closing one of the tags or making a mistake just to
see what is displayed.
It’s important that you see what happens when HTML is not coded
correctly. Not only will it help you understand what an error looks like,
it will remind you to write tags in the right order in future.
This headline on your test page is larger and bolder than the text below.
This is because it is inside a header tag. Header tags come in 6 sizes,
ranging from the largest and most important <h1> to the smallest
<h6>. They are used to display important site headlines and titles on
your page.
From a Search Engine Optimisation point of view, the <h1> tag is the
most important tag in the body of your web page followed by the <h2>
tag.
I encourage you all to edit your test.html file to display all 6 header tags
to see the different in size between them. All you have to do is add
something like this to the body element of your web page.
<h1>This highlights the size and weight of the H1
tag</h1>
<h2> This highlights the size and weight of the H2
tag</h2>
<h3> This highlights the size and weight of the H3
tag</h3>
<h4> This highlights the size and weight of the H4
tag</h4>
<h5> This highlights the size and weight of the H5
tag</h5>
<h6> This highlights the size and weight of the H6
tag</h6>
The DOCTYPE
If you have read chapter 2, you should be familiar with all of the tags
which were used to build our test.html page (except from the header
tags which I just briefly spoke about).
Though you will have noticed this strange piece of code at the very top
of our web page:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
The strict DOCTYPE is specifically for HTML files which only have
HTML 4 tags. No deprecated tags are permitted under this Document
Type Declaration.
Over the years the idea of separately style from content has come more
into play, with CSS controlling the style and visual design of a site with
HTML being used to structure the site. This is nearly always the case
with blog designs, which is why it’s so easy to customise them!
However, there are some HTML tags which are used frequently in all
web pages. In this chapter I will explain the most common HTML
elements which you will find in your blog template.
‘Basic HTML: An Introduction to HTML for bloggers’
By Kevin Muldoon
Paragraphs <p>
In order to display the text correctly, you would use the paragraph <p>
tag and write something like this:
<p>I’m learning HTML</p>
This tells the browser that the two lines are separate from each other
and would give the following output.
I’m learning HTML
Isn’t it a fascinating language!
Through CSS, paragraphs can be used to control how the text appears
and how much space is between each paragraph (amongst other things,
the possibilities are endless!).
I discussed break lines briefly in chapter 2. They are used to tell the
browser to print the rest of the content on the next line. Generally
speaking, paragraphs should always be used to format your main
content area however break lines are very useful in certain situations.
Divisions and spans are mainly used to link to a class within a CSS Style
Sheet. They work in the exactly the same way except that spans are an
in-line element and divisions are a block-line element. A block element
adds a line break so the information is displayed on the next line.
Most blog templates use divisions to design the structure of a blog page.
Spans are mostly used within the body of a text. Divs and spans usually
use an ID (Identifier)or a class.
The division above links to an identifier in our style sheet which centres
the text and changes the font. Within the text we are changing the
colour of the word HTML to green using a class in our style sheet called
class1 and the word fascinating to red using the class class2.
The strong and emphasis tags are used to emphasise text. <em> is used
to emphasise something and <strong> is used to strongly emphasise it.
• <b> and <i> are explicit, which is akin to telling the browser
‘Make this text italic and make this text bold’.
For example, a program which reads text for the blind may change the
tone of the voice for the listener when an emphasis tag is used,
something which wouldn’t occur using the older tags.
Defining Colours
Years ago, the colour of text was defined in
numerous elements of HTML using the
attribute color=”#HEXCODE” (the
attribute bgcolor was also used for
backgrounds). Nowadays colours are
defined in the CSS stylesheet.
The 16 colours are aqua, black, blue, fuchsia, gray, green, lime, maroon,
navy, olive, purple, red, silver, teal, white, and yellow. Although you can
use these names in your style sheet, to adhere to HTML and CSS
validation rules you should link using the hexadecimal code.
Note, you can use any colour in your style sheet, the 16 colours which
the W3C have defined just ensures that older browsers and operating
systems display the colours in the same way. If you use a colour that is
not recognised by an older computer or device with a limited colour
palette, the closest colour will be used (well this is what is supposed to
happen but in my experience it wasn’t always the case!)
W3C also recommend that you use hexadecimal code when referring to
colours instead of the colour name.
• Definition List (<dl>): Definition lists are used for making lists
‘Basic HTML: An Introduction to HTML for bloggers’
By Kevin Muldoon
Using CSS you can display unordered list items by discs, squares,
circles, bullets and much more. It is also possible to list items using an
image therefore how you display your list is limited only by your
imagination.
<li>Bananas</li>
<li>Grapes</li>
</ol>
By using CSS, unordered lists can be so much more than just bullet
points and squares. Most designers use lists to display information on
sidebars, footers and the navigation menus.
Definition Lists
Definition lists work slightly different from ordered and unordered lists.
Instead of just listing an item, you have to define it and then describe it.
You do this using the Definition Term (<dt>) and the Definition
Description (<dd>).
The anchor <a> HTML tag allows you to create a hyperlink on your
blog. It is always used with the attribute href. Any text or images which
are placed between the opening and closing anchor tag will be
hyperlinked to the destination defined by the href attribute.
Not only can you link to websites, you can link to files, images, email
addresses and to a section of the current page!
If your link text is not very descriptive then it can be useful to use the
attribute title. The title attribute helps with accessibility and is worth
using in your navigation menu links.
<a href=”http://www.bloggingtips.com” title=”Blogging
Tips Home Page”>Home</a>
If one of your blog readers clicks on the ‘Email Me’ link above their
chosen email program would create a new email message with the ‘To:’
field already filled in.
<a href=”mailto:email@yourblog.com,
mypartner@yourblog.com”> Email Me</a>
We can extend this even further by placing a question mark (?) at the
end of our email link.
Here is the code for copying in a blog partner in an email and pre
specifying the email message title:
<a href=”mailto:email@yourblog.com?cc=
mypartner@yourblog.com&subject=Blog Feedback”>Email
Me</a>
Note, the ampersand (&) is used to separate different sections after the
question mark.
Linking
Linking within a page or document
It is sometimes necessary to link to a different part of a web page or
document. This is particularly helpful with pages with large amounts of
text. You can do this with HTML be using what is known as a named
anchor.
This anchor link will not be shown anywhere on your web page, you are
simply telling the browser that you would like to link to this area later.
Therefore there is no need to place any text within the link.
To link to your anchor you need to place the hash tag (#) in front of the
anchors name. So to link to the anchor which I defined before I would
use:
<a href=”#name”>Link Name</a>
If you would like to place a link in your footer to the top of a page all
you need to do is add <a ID=”top”></a> just after the <body> tag in
your template and <a href=”#top”>Return To Top Of Page</a> in
your footer somewhere. Alternatively, if you use a CSS identifier for the
structure of your header, you can link to that.
You can also link to specific areas of a different page using anchors. For
example, if your about page has a terms and conditions area you could
link to it directly by placing <a ID=”terms”></a> at the top of the
terms and conditions section. You could then link directly to this area
using www.yourblog.com/about#terms.
It is possible to open a link with a new tab using JavaScript but since
many people turn this feature off, it’s not a great option.
Images are a quick and easy way to make our blogs easier to navigate,
look more professional and improve our blog posts. You can add an
image to a page with HTML by using the image tag <img>.
You will notice that the image tag does not require a closing tag.
The src and alt attributes are required in all images. SRC is the attribute
which you use to link to the image location. Therefore you can link
‘Basic HTML: An Introduction to HTML for bloggers’
By Kevin Muldoon
It is important to make sure that you nest the image inside of the
anchor link correctly. Remember, things can get a little messed up when
you close HTML tags in the wrong order!
Image Types
The three most popular image formats are:
Tables are not widely used to construct the design of a website anymore
due to the development and implementation of CSS (particularly the
use of divisions) so it’s doubtful if you have come across tables before in
a blog design. However, tables remain one of the most popular ways to
display information on a page.
1 2
3 4
The tags used in our example are the most important tags used in the
table element:
The table element has several attributes which let you control how the
table is displayed, the most common ones being:
You can define a header for a data cell using the th element. Most
browsers align the contents of a th element to the centre of the cell and
make the text bold.
<tr>
<td>Row 1 | Cell 1</td>
<td>Row 1 | Cell 2</td>
</tr>
<tr>
<td>Row 2 | Cell 1</td>
<td>Row 2 | Cell 2</td>
</tr>
</table>
When using table headers, it is worth using the attribute scope. You use
scope="col" for a column heading and scope="row" for a row heading.
This is beneficial from an accessibility point of view as it tells the screen
reader what the heading is for ie. a row or column.
Cell Header
1 2
specific way.
The code below was used to design the table on the right. Copy the
code into your test.html page and and change some values to get a
better understanding of how tables work.
<table border="1">
<tr>
<th rowspan="3">Dogs</th>
<td>Greyhound</td>
</tr>
<tr>
<td>Collie</td>
</tr>
<tr>
<td>Spaniel</td>
</tr>
<tr>
<th colspan="2">Cats</th></tr>
<tr>
<td rowspan="2">Tabby</td>
<td>Siamese</td>
</tr>
<tr>
<td>Persian</td>
</tr>
</table>
If you would like to style your tables and present them in a more
appealing way to your blog readers, you should look more into CSS
since attributes like bgcolor have been deprecated (specifically how
tables and CSS work together) ☺
In this chapter I will talk about some other HTML related topics which
I have not discussed in detail up to this point.
Character Entities
There are thousands of character entity references in HTML. These
entities allow you to display thousands of letters, symbols,
mathematical symbols, characters and much more.
The numeric HTML reference for all of these entities is &# followed by
a number followed by ;. Each character/symbol also has a character
‘Basic HTML: An Introduction to HTML for bloggers’
By Kevin Muldoon
Commenting
Like most programming languages, HTML allows you to add
comments in order to document your code. This can be very helpful
when going back to HTML code at a later date or when you are
designing for someone else.
Validation
Throughout this e-book I have spoke about code validation and
deprecated HTML elements (i.e. elements which are not valid in
HTML 4 but still work in most browsers).
Code validation is something that many purists want on the web so that
web pages are displayed correctly on all browsers and devices. It also
takes the right steps towards an accessible website and valid code will
also ensure you don't put up any road blocks to search engine spiders as
they read through your pages
HTML VS XHTML
In January 2000 the World Wide Web Consortium (W3C)
recommended the use of XHTML. XHTML 1.0 was, according to
XHTML 1.0 specification, a ‘reformulation of HTML 4 as an XML 1.0
application’.
HTML 4.01 and XHTML are virtually the same except the latter is
stricter. There's not a lot more that you can do with XHTML that you
can't do with HTML. Code is case sensitive, you cannot leave out a
closing tag and attributes always have to have values.
In July 2009 W3C announced that it was pulling support for XHTML 2
in favour of the upcoming HTML 5.
Many blog templates are coded in XHTML so you will probably see the
differences that I mentioned above in your blog theme.
In this chapter I will give you all a brief introduction to what CSS is and
give you a look at how it integrates with HTML.
Cascading Style Sheets has taken on most of the design aspects that
HTML used to take care of and has made web pages easier to navigate
and easier to modify. Essentially, they allow designers to define style
and formatting details and apply those details to HTML using what is
known as selectors.
Styles can be defined inside the body element though they are usually
defined in the head element, or more commonly, in an external style
‘Basic HTML: An Introduction to HTML for bloggers’
By Kevin Muldoon
sheet.
There are two different HTML elements here: the header element and
the paragraph element. We want to change how both areas are
displayed.
We can style these elements with CSS within the body element (i.e.
within the code itself).
<h1 style=”font-family:Verdana;font-
size:large;color:#ff0000;font-weight:bold;”>A Brief Note
On CSS</h1>
<p style=”font-family:Geneva;color:#000000;”> In this
chapter I will give you all a brief introduction to what
CSS is and give you a look at how it integrates with
HTML.</p>
In the above example I have used CSS to make the headline use the
Verdana font, be large in size, red in colour and bold. The content
within the paragraph will have the Geneva font instead and be printed
in the colour black.
To embed your styles directly within the head element of your page,
you would place this code between the opening and closing <head>
tags.
<style type=”text/css”>
Place your css code here!
</style>
This means that whenever someone uses the H1 or paragraph tags, the
text will be displayed according to what we specified in our style.
The number of CSS styles quickly grows when you are designing a web
page or blog template. Therefore, it is advisable to place all of your CSS
styles in what is known as an External Style Sheet. You simply save all
of your styles in a file with the extension .css and then link to it using:
<link rel=”stylesheet” type=”text/css” href=”style.css”>
The CSS code may still look a little daunting but it is relatively easy to
follow once you break it down.
Each CSS definition has a selector and a declaration block. Within the
declaration block are properties and their corresponding values.
If you are look at your blog template then you will see lots of <div>
elements. Some of which use classes and some of which use IDs e.g.
<div class=”commentarea”> or <div id=”sidebar”>.
Classes and IDs (known as identifiers) can be used with a type or a class
selector however there are some small differences between them:
• You can use multiple classes within the same element eg. <p
class=”big” class=”green”> and you can also use an identifier and a
class in the same element eg. <p id=”firstparagraph” class=”big”
class=”green”>. However, an identifier can only be used once in
one element on any page.
Click on the comment link at the front of any WordPress powered blog
and you will be taken to something like www.yourblog.com/blog-
post#comments if there are comments and taken to the comment
submission form at www.yourblog.com/blog-post#respond if there
aren’t any.
CSS Overview
Just like any new language, CSS can seem a little daunting at first.
Though once you understand the basics of how selectors and
declaration blocks work, you will soon appreciate the beauty of
Cascading Style Sheets.
It just isn’t practical to pay a designer for assistance every time you want
to add a link to your sidebar or change an image in your blogs footer as
these tasks only take seconds to do and are incredibly simple.
I hope that you have enjoyed this e-book and it helps you understand
the HTML language better. At the very least, I hope that you can now
do basic modifications to your blog design without asking for help ☺
come with an integrated contact form already (or at the very least, a
plugin is available to add a contact form).
I wish you all the best of luck with your blogging careers and I hope that
this e-book will help you take your blog to the next level!
Kevin Muldoon
www.bloggingtips.com
Community Support
If you finding any aspect of HTML difficult then I encourage you to
drop by the Blogging Tips Forums for hands on support from
experienced bloggers, webmasters and designers.
It’s a great place to hang out with like minded bloggers and best of all,
registration is free!!
* In no particular order
http://www.htmlcodetutorial.com/
http://www.htmlgoodies.com/
http://htmldog.com/
http://reference.sitepoint.com/html
http://www.w3schools.com/html/DEFAULT.asp
http://www.tizag.com/htmlT/
Release History