Web Design and Development (HTML, CSS and JavaScript)
Web Design and Development (HTML, CSS and JavaScript)
The Web a short form of the World Wide Web (WWW) is an information space where
documents and other web resources identified by Uniform Resource Locators (URLs),
interlinked by hypertext links, and accessible via the Internet are located. Web resources include
websites and web applications. A website is a collection of related web pages, including
multimedia content, typically identified with a common domain name, and published on at least
one web server. Notable examples are wikipedia.org, google.com, and amazon.com. A Web
application (Web app) is an application program or software that is stored on a remote server and
delivered over the Internet through a browser interface. Web design and development is therefore
the discipline concerned with designing and the development of web resources including
websites and web software. In this course we consider website design and development while in
ACSC 327: Web Programming and Administration, we will move on to development of web
applications.
A website is a combination of different web pages linked together in a certain fashion according
to the designer’s will and organizational need served through the same domain name server. The
developed website is prepared and maintained by a person, group or an organization. Website is
typically written in technologies such as HTML, XHTML and DHTML and is hosted on single
web server for its access through network. Each website is provided with a unique uniform
resource locator (URL) and accessed through the hypertext transfer protocol (HTTP) responsible
for making communication possible between client machine and the server by the application of
different browsers. Websites provide hypermedia resources, a system allowing storage and
access to text, graphics, audio and video in so called pages linked to each other in a way that
integrates these different media elements. When a user clicks on a highlighted word or picture
(icon), the browser converts the click to computer commands and brings the requested new
information in the form of text, photograph, chart, song or movie clip to the user's computer.
Web design refers to both the aesthetic portion of the website and its usability. Web design
considers the choice of colors, images, layout and the general look of the website in regard to its
purpose. A web designer for example will consider a party website and choose vibrant colors
such as yellow and orange rather than black and grey. Web Developers on the other hand, take a
website design and actually make a functioning website from it. Web developers use HTML,
CSS, JavaScript, PHP and other programming languages to bring to life the design files.
Web developers as those who turn the designs into a live website. Web developers uses web
languages and software tools to develop the design and functionality of a website. Notice, that
web developers are further split into two sub-categories; front-end developers, and back-end
developers.
A front-end developer is the one who builds the interface, and provides the layout as the
interaction between the back-end of the website and the user. Front-end developers use three
main languages; Hypertext Markup Language (HTML), Cascading Style Sheets (CSS), and
HTML
HTML (Hyper Text Markup Language) is the language for building websites. HTML is not a
programming language but a markup language. HTML was first created by Tim Berners-Lee,
Robert Cailliau, and others starting in 1989. It stands for Hyper Text Markup Language.
Hypertext means that the document contains links that allow the reader to jump to other places in
the document or to another document altogether. The latest version is known as HTML5.
A Markup Language is a way that computers speak to each other to control how text is processed
and presented. To do this HTML uses two things: tags and attributes.
Tags and attributes are the basis of HTML. Tags are used to mark up the start of an HTML
element and they are usually enclosed in angle brackets. An example of a tag is: <h1>. Most tags
must be opened <h1> and closed </h1> in order to function.
Attributes contain additional pieces of information. Attributes take the form of an opening tag
and additional info is placed inside. An example of an attribute is:
In this instance, the image source (src) and the alt text (alt) are attributes of the <img> tag.
Remember:
The vast majority of tags must be opened (<tag>) and closed (</tag>) with the element
information such as a title or text resting between the tags.
When using multiple tags, the tags must be closed in the order in which they were
opened. For example:
HTML Editors
To create a HTML document you need an editor. Examples of editors are Notepad, Sublime Text
3, Notepad++, Komodo Edit and Macromedia Dreamweaver.
<!DOCTYPE html>
<html>
<head>
<title>The title of the Webpage</title>
</head>
<body>
Enter Webpage Contents Here
</body>
</html>
<! DOCTYPE...>
This tag defines the document type and HTML version. The <! DOCTYPE> declaration tag is
used by the web browser to understand the version of the HTML used in the document. Current
version of HTML is 5 and it makes use of the following declaration −
<! DOCTYPE html>
<html>
This tag encloses the complete HTML document and mainly comprises of document header
which is represented by <head>...</head> and document body which is represented by
<body>...</body> tags.
<head>
This tag represents the document's header which can keep other HTML tags like <title>, <link>
etc.
<title>
The <title> tag is used inside the <head> tag to mention the document title.
<body>
This tag represents the document's body which keeps other HTML tags like <h1>, <div>, <p>
etc.
NB: There are many other tags depending on the task to be accomplished, and we will look at
some of them in sections that follow.
Basic Tags
Heading Tag
Any document starts with a heading. You can use different sizes for your headings. HTML also
has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>.
While displaying any heading, browser adds one line before and one line after that heading.
<!DOCTYPE html>
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
Paragraph Tag
<!DOCTYPE html>
<html>
<head>
<title>Setting Basefont Color</title>
</head>
<body>
<basefont face = "arial, verdana, sans-serif" size = "2" color = "#ff0000">
<p>This is the page's default font.</p>
<h2>Example of the <basefont> Element</h2>
<p><font size = "+2" color = "darkgray">
This is darkgray text with two sizes larger
</font>
</p>
<p><font face = "courier" size = "-1" color = "#000000">
It is a courier font, a size smaller and black in color.
</font>
</p>
Lists
There are three list types in HTML:
i. unordered list (bullets) — used to group a set of related items in no particular order
ii. ordered list (numbering) — used to group a set of related items in a specific order
iii. description list — used to display name/value pairs such as terms and definitions
Unordered List
Example
<html>
<head>
<title>Lists in HTML</title>
</head>
<body>
<ul type="square">
<li>bread</li>
<li>coffee beans</li>
<li>milk</li>
<li>butter</li>
</ul>
<ol type="i" start="5">
<li>Gather ingredients</li>
<li>Mix ingredients together</li>
<li>Place ingredients in a baking dish</li>
<li>Bake in oven for an hour</li>
<li>Remove from oven</li>
<li>Allow to stand for ten minutes</li>
<li>Serve</li>
</ol>
<dl>
<dt>ACSC 226</dt>
<dd>Web Design and Development</dd>
There are different types of form controls that you can use to collect data using HTML form:
This control is used for items that require only one line of user input, such as search boxes or
names. They are created using HTML <input> tag.
This is also a single-line text input but it masks the character as soon as a user enters it. They are
also created using HTML <input>tag but type attribute is set to password.
Following is the list of attributes for <input> tag for creating text field.
type - Indicates the type of input control and for text input control it will be set to text.
name - Used to give a name to the control which is sent to the server to be recognized and get the
value.
value - This can be used to provide an initial value inside the control.
size - Allows to specify the width of the text-input control in terms of characters.
maxlength - Allows to specify the maximum number of characters a user can enter into the text
box.
name- Used to give a name to the control which is sent to the server to be recognized and get the
value.
<body>
<form method="post" action="">
<input type = "checkbox" name = "chkmaths" value = "on"> Maths
<input type = "checkbox" name = "chkphysics" value = "on"> Physics
</form>
</body>
</html>
Radio Button Control
Radio buttons are used when out of many options, just one option is required to be selected.
They are also created using HTML <input> tag but type attribute is set to radio.
Following is the list of attributes for radio button.
type- Indicates the type of input control and for checkbox input control it will be set to radio.
name- Used to give a name to the control which is sent to the server to be recognized and get the
value.
value- The value that will be used if the radio box is selected.
checked- Set to checked if you want to select it by default.
<!DOCTYPE html>
<html>
<head>
The following is the list of important attributes for the <option> tag:
value- The value that will be used if an option in the select box box is selected.
selected- Specifies that this option should be the initially selected value when the page loads.
label- An alternative way of labeling options
<!DOCTYPE html>
<html>
<head>
<title>Select Box Control</title>
</head>
<!DOCTYPE html>
<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form method="post" action="">
<input type = "file" name = "fileupload" accept = "image/*" />
</form>
</body>
CSS
CSS is an abbreviation for Cascading Style Sheets. CSS works with HTML and other Markup
Languages (such as XHTML and XML) to control the way the content is presented. Cascading
Style Sheets enables to separate the appearance of a webpage from the content of a webpage.
CSS is a recommendation of the World Wide Web Consortium (the W3C) for defining the
presentation and look of a website. To achieve this, CSS makes use of styles which are presented
in a style sheet.
Advantages of CSS in Web Design and Development
Increases download speed- In a webpage which doesn’t use CSS, the styling is achieved
using formatting tags which in essence overloads the HTML content. HTML was
intended for content not for the look. Use of CSS in a website reduces HTML ‘clutter’
hence compacting the files,
Reduces time spend maintaining the website
A more uniform website
A style sheet consists of one or more rules that describe how document elements should be
displayed. Each rule in CSS has two parts: the selector and the declaration; and the declaration
also has two parts, the property and the value. The selector defines any HTML element for which
a change is deemed necessary e.g. body, p, table, th, hr etc. The declaration contains the property
and value for the selector. The property is the attribute you wish to change and each property can
take a value. The property and value are separated by a colon and surrounded by curly braces:
An example of a CSS Style Sheet rule and component parts is shown below:
h2 {
font-size: 30px;
}
p{
font-size: 14px;
}
Example 7
p.normal {
font-weight: normal;
}
p.thick {
font-weight: bold;
}
Example 8
body {
color: blue;
}
h1 {
color: green;
}
Example 9
h1 {
text-align: center;
}
h2 {
h3 {
text-align: right;
}
Example 10
h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
}
h3 {
text-decoration: underline;
}
a{
text-decoration: none;
}
Example 11
p.uppercase {
text-transform: uppercase;
}
p.lowercase {
text-transform: lowercase;
}
p.capitalize {
text-transform: capitalize;
}
Attaching CSS Styles to Web Development
There are three ways that styles can be associated with an HTML document.
First, styles can be placed inline in a document. Second, a style sheet can be embedded in the
head of an HTML document. The third way of associating web pages with style sheets is to place
a link in the head of the HTML file to an external style sheet. With this link, when the browser
Descendants Selector
It is used to apply a style rule to an element only when it lies inside a particular element. As
given in the following example, the style rule will apply to <em> element only when it lies
inside the <ul> tag.
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
ul em
{
color: maroon;
}
</style>
</head>
<body>
<ul>
<li>
<em>Oranges</em>
</li>
<li><em>Mangoes</em></li>
</ul>
<em>Hello, I am for emphasis</em>
The border property of an image is used to set the width of an image border. This property can
have a value in length or in %.
A width of zero pixels means no border.
<img style="border:0px;" src="/images/css.gif" />
<br />
<img style="border:3px dashed red;" src="/images/css.gif" />
The height property of an image is used to set the height of an image. This property can have a
value in length or in %. While giving value in %, it applies it in respect of the box in which an
image is available.
<img style="border:1px solid red; height:100px;"
src="/images/css.gif" />
<br />
<img style="border:1px solid red; height:50%;"
src="/images/css.gif" />
The border-color property allows you to change the color of the border surrounding an element.
You can individually change the color of the bottom, left, top and right sides of an element's
border using the properties:
border-bottom-color changes the color of bottom border.
border-top-color changes the color of top border.
border-left-color changes the color of left border.
border-right-color changes the color of right border.
<style type="text/css">
p.example1{
border:1px solid;
border-bottom-color:#009900; /* Green */
border-top-color:#FF0000; /* Red */
border-left-color:#330000; /* Black */
border-right-color:#0000CC; /* Blue */
}
p.example2{
border:1px solid;
border-color:#009900; /* Green */
Margin
The margin property defines the space around an HTML element. It is possible to use negative
values to overlap content. The values of the margin property are not inherited by the child
elements. Remember that the adjacent vertical margins (top and bottom margins) will collapse
into each other so that the distance between the blocks is not the sum of the margins, but only the
greater of the two margins or the same size as one margin if both are equal.
We have the following properties to set an element margin.
· The margin specifies a shorthand property for setting the margin properties in one declaration.
· The margin-bottom specifies the bottom margin of an element.
· The margin-top specifies the top margin of an element.
· The margin-left specifies the left margin of an element.
· The margin-right specifies the right margin of an element.
myJavascript.js
function sayHello()
Javascript Syntax
• Semi colons are optional- Simple statements in JavaScript are generally followed by a
semicolon character, just as they are in C, C++, and Java. JavaScript, however, allows you to
omit this semicolon if each of your statements are placed on a separate line.
• JavaScript is a case-sensitive language- This means that the language keywords, variables,
function names, and any other identifiers must always be typed with a consistent
capitalization of letters.
• Comments- JavaScript supports both C-style and C++-style comments. Thus:
Single line comments:
// Single line comment
Or
<!--. Single line comments //-->.
Multiline comments
/* multiline comments */
Javascript Variables