21 Website Authoring
21 Website Authoring
21 Website Authoring
Hypertext Markup Language, or HTML, is the computer language used for website creation.
Cascading Style Sheets (CSS) is a simple design language used to make web pages more
presentable.
A simple text editor can be used to create websites. Users can opt for Notepad on Windows or
Text Editor on Mac. After the codes have been typed in, the file should be saved with an .html
or .htm extension. Double-clicking on the saved file will cause the webpage to be opened on a
browser.
Both HTML and CSS codes are based on tags – labels used to mark the beginning and end of an
element. The starting tag is marked between < and >. Ending tags are marked between </ and >.
Indentation should be used, to ensure code readability, as in the example below.
In certain situations, CSS tags may be enclosed with curly brackets – { and }.
All HTML documents begin with a document type declaration <!DOCTYPE html>.
HTML comments can be added anywhere in the HTML document. They are identified by the <!--
and --> tags. Anything that is written in between these tags are ignored by the program. They
exist as memos and notes to programmers.
Some tags are standalone. There is no need to add any information to the tags to make them
work. Other tags depend on additional information, which are included in tag attributes. These
attribute values are included inside the opening tag.
All HTML tags and other codes are in American English. Codes that are spelt wrongly, or in the
British English spelling convention, would not be recognized.
Metadata is data that provide information about other data. It is usually hidden within
applications and stored within a document. These information can include:
Your name and initials.
Company name.
Computer name.
Location of document on local or network server.
Attached template.
Hidden text.
Comments.
Track changes.
File properties.
System summaries.
HTML metadata can contain several attributes and are defined by the <meta> tag. Charset
declares the document’s character encoding. By default, the charset for HTML 5 documents is
“utf-8”. Keywords show the search terms that would call up this webpage. Description shows a
general explanation on the website. Author shows the name of the author(s) of the webpage.
All HTML codes begin with <html> and ends with </html>. A header houses the title of the
website and is enclosed between <head> and </head>. The title itself uses the <title> and </title>
tags. Some other tags are included in the head tag. These include:
Tag Description Example
<base> Specifies a <base href="https://www.w3schools.com/images/"
default URL and target="_blank">
default target
for all links on a
page.
<link> Links an <link rel=” stylesheet” type=”text/css” media=”screen”
external file into href=”css/styles.css”>
the HTML file.
Most of the
time, the file
linked is a CSS
external
stylesheet.
<meta> Includes <meta name=” keywords” content=”computer science,
keywords and programming, code, STEM, tutorials, education”>
descriptions
that would be
used by search
engines to
discover and
search through
the website.
<style> Includes CSS <style type="text/css">
scripts. body {
background-color: #000000;
color: #FFF000;
font-family: Arial, Helvetica, sans-serif;
}
</style>
<script> Includes <script src="js/main.js">
JavaScript </script>
coding.
<title> Includes a name <title>WMSKLI Photography Club</title>
for the title of
the website.
In HTML, it is sometimes useful to show information in a table format. The tags used in a table
includes:
Code Description
<table></table> Creates a table.
<tr></tr> A row in the table.
<td></td> A table cell.
<caption> </caption> Table caption that is displayed above the table.
<table border> Draws a border around the table – 1 draws the borders, “” leaves
the borders out.
<thead></thead> Enclose a group of rows in a table as a header.
<tbody></tbody> Main body of the table.
<tfoot></tfoot> Enclose a group of rows in a table as a footer, such as last row for
summary.
<th></th> Define the content of a header cell.
Inline text or embedded code is defined within a tag. It should only be used if that style will not
be repeated anywhere on the webpage or website. The format used is <element style=”property:
value”>. There is no need for the usual CSS curly brackets.
Internal stylesheet is written in the head part of the HTML page. It must be repeated in every
webpage where it is used.
An external stylesheet is saved as a separate file. It is included into the HTML file as a link.
Column widths are fixed with the width element, followed by a colon and a percentage. To fix
the width of a column, the following codes can be used:
Keyword Values Description
auto Value determined by other CSS properties
px Pixels
em Relative to the font-size of the element
Inherit Inherits from the parent element
Initial Sets the property to default value
Unset Resets a property to its inherited value if it inherits from its
parent, and to its initial value if not
Text can be aligned using the text-align element. This is used in conjunction with the following
values:
Left.
Right.
Center.
Justify.
Justify all.
CSS can also be used to set the vertical alignment in tables, using the vertical-align element, and
the following values:
Baseline.
Sub.
Super.
Text-top.
Text-bottom.
Middle.
Top.
Bottom.
%.
Length.
Different alignment styles can be selected for different needs. Tables that are included in formal
reports would require a more formalized look, thus a middle justified or middle left alignment
would be used. The inclusion of images in tables would also affect the alignment of the cells.
The most common cell alignments are shown in the image to the left.
There are two important codes that can be used to merge cells. These are colspan and rowspan.
These codes are used with a
positive integer with a value
of 2 or higher.
To remove the border space, users can type in border-collapse: collapse; in place of the border-
spacing code.
Images can be used to enhance a website. These images should be uploaded directly onto a
website first, using ftp technology. The image formats that are supported are:
JPEG.
GIF.
PNG.
SVG.
BMP.
To insert an image directly into a webpage, we can use the img src tag, which is a standalone tag.
The source should include the full web address if it is embedded in another website. If it has
been uploaded directly into the current website, however, only the name will suffice. For
example, to insert an image called Pic1.jpg, the code used should be <img src=”Pic1.jpg”>. The
image can be positioned correctly on the website, using the align properties.
The alt property allows an image to be given an alternative name, which would appear on the
top left corner of the image box if the image does not load.
Images can be resized directly in HTML, or they can be resized first in an external application and
inserted into HTML. An image that has been resized in an external application will load faster.
This is because an image is loaded in its original size into HTML. To resize an image in HTML, the
width and height properties can be used. To change the size of flower.jpg to 400px x 200px, we
can use the code <img src=”flower.jpg” width=400 height=200 alt=”flower”>.
You can also resize the same image using CSS codes:
img.resize {
width: 400px;
height: 200px;
}
Animated images in gif format can be added to HTML webpages using the same codes.
The controls attribute for both video and audio allow the users to add controls like play, pause
and volume.
There are also currently 140 colour names that are recognized by HTML. These names can be
used directly in HTML codes, and include common colours like red, green, blue, yellow and black,
to name a few. A list of the updated colour names can be found online.
Background colours are set in the HTML body tag. The code for the tag is <body
style=”background-color: rgb (255, 0, 0);”></body> or <body style=”background-color:
#FF0000”;”></body>.
Font, header, paragraph and table colours can be changed, using the same color properties.
Lists are used to group together items or pieces of information that are related to each other.
There are three types of lists in HTML:
Ordered lists.
Unordered lists.
Description lists.
The <li></li> tags are used to define items in an ordered or unordered list.
Ordered lists or numbered lists are used to display a list of items in a specific order. An ordered
list is listed as a set of <ol></ol> tags wrapping around one or more sets of <li></li> tags.
Unordered lists are used when a set of items can be placed in any order. They are often referred
to as bulleted lists. An unordered list uses <ul></ul> tags around one or more sets of <li></li>
tags.
Description lists or definition lists are used to link specific names and values to a list. You can
link several values to a single name, or link more than one name with the same value. The
<dl></dl> tags are used to wrap around <dt></dt> tags, which represent names and <dd></dd>
tags, which represent values.
<dl>
<dt>coffee</dt>
<dd>a beverage made from roasted, ground coffee beans</dd>
<dd>a medium to dark brown colour</dd>
<dt>soda</dt>
<dt>pop</dt>
<dt>fizzy drink</dt>
<dt>cola</dt>
<dd>a sweet, carbonated beverage</dd>
</dl>
An individual list can contain another list. This is known as a nested list.
<ul>
<li>James</li>
<ul>
<li>Extended Maths</li>
<li>Physics</li>
<li>Chemistry</li>
</ul>
<li>Joanne</li>
<ul>
<li>Standard Maths</li>
<li>Biology</li>
</ul>
</ul>
A hyperlink is used to access another webpage or document. By default, text hyperlinks are
underlined and in blue. The <a></a> tags, also known as anchors, are used to define links. For
example, to link to Google.com, you simply type <a href=”http://www.google.com”>Google</a>.
Absolute addresses, which allows a user to link directly to files on a physical hard drive, should
not be used in HTML links. Therefore, a user should not use “C:/Documents/Trial.doc” in an
anchor tag.
To ensure that the hyperlink opens in a new tab, the target attribute can be used:
<a href=”http://www.fairview.edu.my” target=”_blank”>Fairview International School</a>
You can also choose to link to a division or section of an HTML page. This is known as a division.
Developers often choose to group elements together in a <div></div> tag to slice up documents.
To link to divisions in the webpage, simply add the following code where required:
<p>There are two sections in this document – <a href=”subDiv1”>Section 1</a> and <a
href=”subDiv2”>Section 2</a>.</p>
Sometimes it is necessary to add in a link to an email, for the convenience of purchase orders
and enquiries. To create a hyperlink to an email package, you can start use mailto: instead of
http:
An image can be used as a hyperlink. To use the image envelope.jpg as a hyperlink to Google
Mail, type in the following code:
<a href=”http://gmail.com”>
<img src=”envelope.jpg” width=100 height=50 alt=”Google Mail”>
</a>
The value of 12 pixels is given to the property of font size, and the value of blue to the property
of color, to be applied to the h1 selector, in the example above.
If there is more than one value associated with a property, they are divided by a comma, like this:
h2 {font-family: “Times New Roman”, “Book Antiqua”}.
An external stylesheet, as mentioned earlier, consists of only CSS codes. These external
stylesheets can be reused repeatedly and are especially helpful in ensuring that corporate styles
are kept to.
The <link> tag in the head of an HTML page is used to link to the required external stylesheet.
There is no limit to the number of stylesheets that can be linked to a single HTML page.
For example, a CSS external stylesheet called stylesheet.css can contain the following codes:
h1 {
text-align: center;
font-size: 12pt;
color: #000099;
margin-bottom: 5px;
text-decoration: underline;
}
In the accompanying HTML file, the user would just need to type the following codes:
<!DOCTYPE HTML>
<html>
<head>
<title>Embedded Style Sheet</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div>
<h1>All-time Home Run Record</h1>
</div>
</body>
</html>
This will make the header in the HTML file follow the styles set in the CSS document.
Stylesheet comments start with /* and ends with */. Just like in HTML, the comments are used
by programmers to divide the code into readable chunks, to identify the functions of different
sections of codes, and to test certain chunks of code for bugs.
If two or more styles share the same values and properties, they can be grouped together with a
single declaration: h1, h2, h3, h4, h5, h6, p {font-family: “Arial”}.
To specify a font for an element, individual font
names can be used, as in the above examples.
However, users can also opt to use generic font
families. These must be added after other preferred
fonts, and include:
Serif
Sans-serif
Cursive
Monospace
Fantasy
Font size can be measured in absolute or relative values in websites, just as in documents.
Absolute font sizes are specific and set to the number of points, picas or pixels. Relative values
are based on previously defined values, like percentages, ems or exes (an ex is half the height of
the letter ‘x’ in the current font size).
There is also a list of predefined relative sizes that the user can choose from:
xx-small
x-small
Small
Medium
Large
x-large
xx-large
In addition to using HTML, text can also be aligned using the CSS property text-align, which has
the following values:
Left
Center
Right
Justify
Text enhancement in CSS is a little more complicated than in HTML. To use bold, italics and
underlined text, font-style, font-weight and text-decoration properties can be used. Type in the
following code:
p{
font-family: “Arial”, “Calibri”, sans-serif;
font-style: italic;
font-weight: bold;
text-decoration: underline;
}
The background of a webpage can be changed according to needs and preferences. Users can
choose to change the background colour of a webpage, or to put an image as the background of
the page. The body tag can be adjusted for this.
To change the background colour of a webpage, the background-color property can be used.
body {
background-color: green;
}
The background-image property is followed by a colon, the word url, and brackets, followed by
the address and name of the image, in quotation marks.
The background-repeat property has three values – repeat, repeat-x and repeat-y.
Finally, the background-position property has five values – top, bottom, right, left and center.
body {
background-image: url(“logo.jpg”);
background-repeat: repeat;
background-position: top center;
}
Classes are reusable styles that can be added to HTML elements. A CSS class can be defined by
using a . in front of a selector.
An example of a CSS class declaration is .blue-text {color: blue;}. In HTML, the class is applied by
using <h2 class=”blue-text”>How to Use Classes</h2>. The class name in HTML does not include
the period.
Classes can also be used as subtypes within an element. For example, the following code defines
a style for h1, with the text aligned left, and a class with the text in the center, in grey.
h1 h3 {
text-align: left
}
.center {
color: #888888;
text-align: center;
}
The following codes would ensure that the third sentence is centralised:
<h1>Example</h1>
<h3>This is in h3 style.</h3>
<h3 class=”right”> This is a subtype of h3 called right.</h3>
CSS can be used to style tables. Table headers, footers and cells can all be styled using the same
properties and values that are applicable to other elements in a webpage.
To style a class, it is easiest to first declare a class for the table. As modern browsers do not
recognise border spacing, we can use border-collapse: collapse; to ensure there is no gap
between table cells.
.pretty-table {border-collapse: collapse;}
.pretty-table th, .pretty-table td {padding: 0.5em;}
By default, most tables in webpages do not have borders. CSS allows a user to declare borders
around individual cells, table rows or the whole table.
Webpages stay in folders after being created. To ensure that other people can see your website,
it needs to be uploaded, tested and published.
All websites have a domain name that is used to find the site. The domain name must be
registered with a host company. Some popular hosting companies include GoDaddy, HostGator,
Exabytes and SiteGround.
Once the domain is registered, the files are uploaded on the website. File transfer protocol (FTP)
is used to upload files from the computer onto the web hosting space. Most modern FTP
applications allow users to drag and drop files into their system for convenience.
A website should be tested before it is published. Every element of the website should be tested
before it is even uploaded to the domain.
A test plan is used to ensure that nothing would go wrong with the website. The testing should
consist of two phases:
Functional testing or usability testing.
User testing or acceptance testing.
In functional testing, all page elements should be checked to ensure that they appear as
expected.
Some of the tests completed in the functional testing phase are included below:
Is the navigation from page to page intuitive?
Are the stylesheets attached?
Are fields easy to fill up, and correct?
Is the website aesthetically pleasing?
Is the information displayed on each page relevant and well organized?
Is the website’s navigation easy to learn and remember?
In user testing:
1. A few people are selected as the test audience.
2. The programmer decides what to test.
3. Create a timeline for testing.
4. The testers look through the system.
5. The programmer then asks the users questions and notes down the test results.
It is often difficult to justify why certain elements are tested in certain ways. Programmers must
be able to determine the elements that belong to functional testing, and those that belong to
user testing.
Websites can be printed out when needed. To print out an entire website:
1. Open the Internet browser program.
2. Surf to the webpage required.
3. Right-click on the webpage and select Print.
4. Configure your print settings accordingly.
21.5 References
Beginner’s Guide to HTML, CSS Background Color and Image, Accessed 31 July 2018
Beta Breakers, Functional Testing vs. Usability Testing, Accessed 31 July 2018
Computer Hope, How to Resize an Image with HTML, Accessed 30 July 2018
FatLab Web Support, How to Setup a Testing Plan Before Launching Your New Website, Accessed
1 August 2018
Free Code Camp, Basic CSS: Use a CSS Class to Style an Element, Accessed 31 July 2018
HTML.com, HTML Comments: How to Use Them in Your Code (AKA <!-- -->), Accessed 25 June
2018
IronSpider, More HTML Font Styles – Bold/Italic Codes, Accessed 26 June 2018
LearnWebCode, HTML Lesson 4: How to Insert an Image in HTML, Accessed 3 July 2018
MakeAWebsiteHub.com, The Best HTML & CSS Friendly Safe Web Fonts to Use in 2018, Accessed
31 July 2018
MDN Web Docs, <meta>: The Metadata Element, Accessed 4 October 2021
Mozilla Developer, <audio>: The Embed Audio Element – HTML, Accessed 30 July 2018
SitePoint, A Walkthrough of CSS Length Units You can Use for Font Size, Accessed 31 July 2018
The HelloWorld Program, HTML Head, Title, Meta, Link and Script Elements, Accessed 25 June
2018
Tutorials 4U, Inline, Embedded and External Styles, Accessed 26 June 2018
Universal Class, Styling Text, Font, and Properties in CSS Designs, Accessed 31 July 2018
Webucator, How to Create a CSS External Style Sheet, Accessed 31 July 2018