Chapter Two
Chapter Two
A web designer works on the appearance, layout, and, in some cases, content of a website.
Appearance, for instance, relates to the colors, font, and images used. Layout refers to how
information is structured and categorized. A good web design is easy to use, aesthetically
pleasing, and suits the user group and brand of the website. The two most common methods for
designing websites that work well both on desktop and mobile are responsive and adaptive
design. In responsive design, content moves dynamically depending on screen size; in adaptive
design, the website content is fixed in layout sizes that match common screen sizes. Preserving a
layout that is as consistent as possible between devices is crucial to maintaining user trust and
engagement.
Basics of HTML
HTML stands for Hypertext Markup Language. It is used to design web pages using a markup
language. HTML is the combination of Hypertext and Markup language. Hypertext defines the
link between the web pages. A markup language is used to define the text document within tag,
which defines the structure of web pages. This language is used to annotate (make notes for the
computer) text so that a machine can understand it and manipulate text accordingly. Most
markup languages (e.g. HTML) are human-readable. The language uses tags to define what
manipulation has to be done on the text. In another word, markup language is a computer
language that defines the structure and presentation of raw text.
All HTML tags must enclosed within < > these brackets.
Every tag in HTML performs different tasks.
If you have used an open tag <tag>, then you must use a close tag </tag>
(except some tags)
HTML has also an attribute that provides additional information about the html elements.
Example <body bgcolor=”red”> tells the browser that the background of the page should be red.
Attributes always come in name/value pairs like name=value. Attributes are always added to the
start tag of an HTML element. Attribute values should always be enclosed in quotes. Double
style quotes are the most common, but single style quotes are also allowed. In some rare cases,
like when attribute value itself contains quotes, it is necessary to use single quotes. Example
name=’John “ShotGun” Nelson ’
Nested HTML element is an HTML element, which is used inside another HTML Element.
Here, <html> tag contains the <head> and <body>. The <head> and <body> tag contains
another elements so it is called nested element. In HTML concept, there are an HTML element
which do not require to have start tag and end tag, some elements does not have content and end
tag such elements are known as Void elements or empty elements. These elements are also called
as unpaired tag. Some Void elements are <br> (represents a line break), <hr> (represents a
horizontal line), <img> (used to embed an image in an HTML page) and etc.
Syntax: <tag>Contents</tag>. HTML elements and tags can be shown as follows:
The following HTML code defines ways of using tags and elements
<html>
<head>
<title>WebPage</title>
</head>
<body>
<h1>This is my first web page</h1>
</body>
</html>
HTML Formatting refers to the enhancing of text in order to increase the visual appeal. HTML
provides a range of formatting tags that can be used to make the text attractive to the users. The
followings are some of HTML text formatting techniques we can apply using commonly known
HTML tags.
HTML Headings
HTML headings range from 1 to 6. The heading defined within <h1> is the more important i.e.
larger font-size and font-weight whereas <h6> is the least important i.e. least font-size. Example:
<html>
<head> <title>Data Flair</title>
</head>
<body>
<h1>Data Flair Heading 1</h1>
<h2>Data Flair Heading 2</h2>
<h3>Data Flair Heading 3</h3>
<h4>Data Flair Heading 4</h4>
<h5>Data Flair Heading 5</h5>
<h6>Data Flair Heading 6</h6>
</body>
</html>
This is defined by the <b> tag. This is a physical tag which is used to display the text in Bold.
For example:
<html>
<head>
<title>Data Flair</title>
</head>
<body>
<p><b>Welcome to Data Flair!</b></p>
</body>
</html>
It displays the content in a manner such that it appears as important. For Example:
<html>
<head>
<title>Data Flair</title>
</head>
<body>
<p><strong>Welcome to Data Flair!</strong></p>
</body>
</html
In HTML, the text can be underlined using the <u> element, in order to emphasize on its
importance. For example:
HTML Highlight
In HTML, the <mark> element is used to highlight the text. For example:
<html>
<head>
<title>Data Flair</title>
</head>
<body>
<p><mark>Welcome to Data Flair!</mark></p>
</body>
</html>
This element is used to define small texts, which can be used to add comments, notes, copyright,
etc. For example:
<html>
<head>
<title>Data Flair</title>
</head>
<body>
<p><small>Welcome to Data Flair!</small></p>
</body>
</html>
<html>
<head>
<title>Data Flair</title>
</head>
<body>
<p><small>Welcome to Data Flair!<sup>E-learning!</sup></small></p>
<p><small>Welcome to Data Flair!<sub>E-learning!</sub></small></p>
</body>
</html>
The <i> element is used to display the text it contains in italics. The <em> element displays the
text in italics along with semantic importance i.e. it emphasizes the text. For example:
<html>
<head>
<title>Data Flair</title>
</head>
<body>
<p><i>Welcome to Data Flair!</i></p>
<p><em>Welcome to Data Flair!</em></p>
</body>
</html>
The <div> and <span> elements are used to group similar content together and create sections or
subsections. The <span> element groups inline elements only. For example:
<html>
<head>
<title>Data Flair</title>
</head>
<body>
<div id = "menu" align = "middle" >
<a href = "#">HOME</a> |
<a href = "#">CONTACT</a> |
<a href = "#">ABOUT</a>
</div>
<p>This is the example of <span>span tag</span>
</p>
</body>
</html>
To set the background color in HTML, use the style attribute. The style attribute specifies an
inline style for an element. The attribute is used with the HTML <body> tag, with the CSS
property background-color. HTML5 do not support the <body> tag bgcolor attribute, so the CSS
style is used to add background color. The bgcolor attribute deprecated in HTML5. Example, we
can use the following code to set the background color in HTML:
<head>
</head>
<body style="background-color:grey;">
<h1>Products</h1>
</body>
</html>
<style>
.div-1 {
background-color: #EBEBEB;
}
.div-2 {
background-color: #ABBAEA;
}
.div-3 {
background-color: #FBD603;
}
</style>
<body>
<div class="div-1"> First Element </div>
<div class="div-2"> Second Element </div>
<div class="div-3"> Third Element </div>
</body>
<html>
<head>
<title>Frame tag</title>
</head>
<frameset cols="25%,50%,25%">
<frame src="frame1.html" >
<frame src="frame2.html">
<frame src="frame3.html">
</frameset>
</html>
Disadvantages of Frames
There are few drawbacks with using frames, so it is never recommended to use frames in in
developing webpages. The followings are some of the disadvantages of using frame:
Some smaller devices cannot cope with frames often because their screen is not big
enough to be divided up.
Sometimes your page will be displayed differently on different computers due to different
screen resolution.
The browser's back button might not work as the user hopes.
There are still few browsers that do not support frame technology.
The main advantage of frames is that it allows the user to view multiple documents
within a single Web page.
It is possible to load pages from different servers in a single frameset.
The concern that older browsers do not support frames can be addressed using the
<noframe> tag. This tag provides a section in an HTML document to include alternative
content for browsers without support for frames. However, it requires that the Web
designer provide two formats for one page.
Tables in HTML
Tables are used are used a great deal in the creation of web pages. They are used to create
boundaries that makes positioning easier. Tables are also used to in the formatting of forms in
which the users are going to submit the information.
The <Table ></Table> element has four sub elements:
Table Row <TR></TR>
Table Header <TH></TH>
Table Data<TD></TD> and
Caption < Caption></ Caption>
Cellspan- specifies how many cell columns of the table this cell should span
RowSpan- specifies how many cell rows of the table this cell should span
HTML Tips- making the table center can be done by using the method of
centering. First we insert the <center></center> element, then we drag the
table inside the <center></center> element. Different browsers accept this
method of creating the table.
<TR>
<TH>Column 1 Header</TH>
<TH>Column 2 Header</TH>
</TR>
<TR>
</TR>
<TR>
</TR>
<TR>
</TR>
</TABLE>
An HTML form is a section of a document which contains controls such as text fields, password
fields, checkboxes, radio buttons, submit button, menus etc. An HTML form facilitates the user
to enter data that is to be sent to the server for processing such as name, email address, password,
phone number, etc. Users generally complete a form by modifying its controls e.g. entering text,
selecting items, etc. and submitting this form to a web server for further processing. form
element is used to create an HTML form for users input. It has the following syntax.
Input Element- input element is the most commonly used element within HTML forms. It
allows you to specify various types of user input fields, depending on the type attribute. An
input element can be of type text field, password field, checkbox, radio button, submit
button, reset button, and file select box etc.
Text Fields- are one-line areas that allow the user to input text. Single-line text input
controls are created using an <input> element, whose type attribute has a value of text.
Here's an example of a single-line text input used to take username:
<form>
<label for="username">Username:</label>
</form>
<form>
<label for="user-pwd">Password:</label>
</form>
Radio Buttons- Radio buttons are used to let the user select exactly one option from a
pre-defined set of options. It is created using an <input> element whose type attribute
has a value of radio. Example: to accept users gender:
<form>
<label for="male">Male</label>
<label for="female">Female</label>
</form>
<form>
<label for="soccer">Soccer</label>
<label for="cricket">Cricket</label>
<label for="baseball">Baseball</label>
</form>
File Select box- The file fields allow a user to browse for a local file and send it as
an attachment with the form data. Web browsers such as Google Chrome and
Firefox render a file select input field with a Browse button that enables the user to
navigate the local hard drive and select a file. This is also created using
an <input> element, whose type attributes value is set to file. Example:
<form>
<form>
<label for="address">Address:</label>
Select Boxes- A select box is a dropdown list of options that allows user to select one or
more option from a pull-down list of options. Select box is created using
the <select> element and <option> element. The <option> elements within
the <select> element define each list item.
<form>
<label for="city">City:</label>
<option value="sydney">Sydney</option>
<option value="melbourne">Melbourne</option>
<option value="cromwell">Cromwell</option>
</select>
</form>
</form>