Web Design Programming Chapter 2
Web Design Programming Chapter 2
Static web Page:- A static web page (sometimes called a flat page/stationary
page) is a web page that is delivered to the user exactly as stored, in contrast to dynamic web
pages which are generated by a web application.
Static web pages are often HTML documents stored as files in the file system and made available by
the web server over HTTP (nevertheless URLs ending with ".html" are not always static). However,
loose interpretations of the term could include web pages stored in a database, and could even
include pages formatted using a template and served through an application server, as long as the
page served is unchanging and presented essentially as stored.
Advantages of a static website
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Example Explained
• The <!DOCTYPE html> declaration defines this document to be HTML5
• The <html> element is the root element of an HTML page
• The <head> element contains meta information about the document
• The <title> element specifies a title for the document
• The <body> element contains the visible page content
• The <h1> element defines a large heading
• The <p> element defines a paragraph
HTML Tags
HTML tags are element names surrounded by angle brackets:
Note: The start tag is also called the opening tag, and the end tag the closing
tag.
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
Web Browsers
The purpose of a web browser (Chrome, IE, Firefox, Safari) is to read HTML
documents and display them.
The browser does not display the HTML tags, but uses them to determine how
to display the document:
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
</html>
Note: Only the content inside the <body> section (the white area above) is
displayed in a browser.
It must only appear once, at the top of the page (before any HTML tags).
<!DOCTYPE html>
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Example
<a href="https://www.Ethioservices.com">This is a link</a>
Example
<img src="img_university.jpg">
Example
<img src="img_university.jpg" width="500" height="600">
The image size is specified in pixels: width="500" means 500 pixels wide.
The value of the attribute can be read by screen readers. This way, someone
"listening" to the webpage, e.g. a blind person, can "hear" the element.
Example
<img src="img_girl.jpg" alt="Girl with a jacket">
The alt attribute is also useful if the image does not exist:
Example
<p style="color:red">I am a paragraph</p>
Example
<p title="I'm a tooltip">
This is a paragraph.
</p>
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
2.5 HYPER-LINKS
HTML links are hyperlinks.
When you move the mouse over a link, the mouse arrow will turn into a little
hand.
Note: A link does not have to be text. It can be an image or any other HTML
element.
Example
<a href="https://www.jitendracourse.com/html/">Visit my HTML tutorial</a>
The link text is the visible part (Visit our HTML tutorial).
Clicking on the link text will send you to the specified address.
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML
tutorial" style="width:42px;height:42px;border:0;">
</a>
Each table row is defined with the <tr> tag. A table header is defined with
the <th> tag. By default, table headings are bold and centered. A table
data/cell is defined with the <td> tag.
Example
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Example
table, th, td {
border: 1px solid black;
}
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
Example
<img src="img_girl.jpg" alt="Girl in a
jacket" style="width:500px;height:600px;">
Example
<img src="/images/html5.gif" alt="HTML5
Icon" style="width:128px;height:128px;">
Actually, you can access images from any web address in the world:
Example
<img src="https://www.ethiopianservices.com/images/ethiopian_green.jpg" alt="
EthiopianServices.com">
Animated Images
HTML allows animated GIFs:
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
Example
<img src="programming.gif" alt="Computer
Man" style="width:48px;height:48px;">
Image Floating
Use the CSS float property to let the image float to the right or to the left of a
text:
Example
<p><img src="smiley.gif" alt="Smiley
face" style="float:right;width:42px;height:42px;">
The image will float to the right of the text.</p>
Background Image
To add a background image on an HTML element, use the CSS
property background-image:
Example
To add a background image on a web page, specify the background-image
property on the BODY element:
<body style="background-image:url('clouds.jpg')">
<h2>Background Image</h2>
</body>
Submit
<form>
.
form elements
.
</form>
Form elements are different types of input elements, like text fields,
checkboxes, radio buttons, submit buttons, and more.
Type Description
<input type="radio"> Defines a radio button (for selecting one of many choices)
Text Input
<input type="text"> defines a one-line input field for text input:
Example
<form>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
</form>
Example
<form>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
</form>
The form-handler is typically a server page with a script for processing input
data.
Example
<form action="/action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
Normally, the form data is sent to a web page on the server when the user
clicks on the submit button.
In the example above, the form data is sent to a page on the server called
"/action_page.php". This page contains a server-side script that handles the
form data:
<form action="/action_page.php">
The default value is "_self" which means the form will be submitted in the
current window.
To make the form result open in a new browser tab, use the value "_blank":
Example
<form action="/action_page.php" target="_blank">
Example
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
Example
<option value="fiat" selected>Fiat</option>
Example
<textarea name="message" rows="10" cols="30">
The cat was playing in the garden.
</textarea>
The rows attribute specifies the visible number of lines in a text area.
Example
<button type="button" onclick="alert('Hello World!')">Click Me!</button>
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
<form>
<fieldset>
<legend>Personalia:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
</form>
Example
<form>
User name:<br>
<input type="text" name="username"><br>
User password:<br>
<input type="password" name="psw">
</form>
Example
<form>
<input type="checkbox" name="vehicle1" value="Bike"> I have a bike<br>
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
Some smartphones recognize the email type, and adds ".com" to the keyboard
to match email input.
Example
<form>
E-mail:
<input type="email" name="email">
</form>
Example
<form action="/action_page.php" method="get">
or:
Example
<form action="/action_page.php" method="post">
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
However, when GET is used, the submitted form data will be visible in the
page address field:
/action_page.php?firstname=Mickey&lastname=Mouse
Notes on GET:
Notes on POST:
• POST has no size limitations, and can be used to send large amounts of
data.
• Form submissions with POST cannot be bookmarked
HTML5 offers new semantic elements that define the different parts of a web
page:
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
• HTML tables
• CSS float property
• CSS framework
• CSS flexbox
• Use the frameset element in place of the body element in an HTML document.
• Use the frame element to create frames for the content of the web page.
• Use the src attribute to identify the resource that should be loaded inside each frame.
• Create a different file with the contents for each frame.
Let’s look at a few examples of how this works. First we need a few HTML documents
to work with. Let’s create four different HTML documents. Here’s what the first will
contain:
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
The first document we’ll save as frame_1.html. The other three documents will have
similar contents and follow the same naming sequence.
Example
Describe metadata within an HTML document:
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
<head>
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="John Doe">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
The <meta> tag provides metadata about the HTML document. Metadata will
not be displayed on the page, but will be machine parsable.
Meta elements are typically used to specify page description, keywords, author
of the document, last modified, and other metadata.
The metadata can be used by browsers (how to display content or reload page),
search engines (keywords), or other web services.
Tag Description
<details> Defines additional details that the user can view or hide
• color • autocomplete
• date • autofocus
• datetime • form
• datetime-local • formaction
• email • formenctype
• month • formmethod
• number • formnovalidate
• range • formtarget
• search • height and width
• tel • list
• time • min and max
• url • multiple
• week • pattern (regexp)
• placeholder
• required
• step
Type Example
Tag Description
<source> Defines multiple media resources for media elements (<video> and
<audio>)
<track> Defines text tracks for media elements (<video> and <audio>)
A home page could normally be split into sections for introduction, content, and
contact information.
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
Example
<section>
<h1>WWF</h1>
<p>The World Wide Fund for Nature (WWF) is....</p>
</section>
An article should make sense on its own, and it should be possible to read it
independently from the rest of the web site.
• Forum post
• Blog post
• Newspaper article
Example
<article>
<h1>What Does WWF Do?</h1>
<p>WWF's mission is to stop the degradation of our planet's natural
environment,
and build a future in which humans live in harmony with nature.</p>
</article>
Example
<article>
<header>
<h1>What Does WWF Do?</h1>
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
<p>WWF's mission:</p>
</header>
<p>WWF's mission is to stop the degradation of our planet's natural
environment,
and build a future in which humans live in harmony with nature.</p>
</article>
Example
<footer>
<p>Posted by: Hege Refsnes</p>
<p>Contact information: <a href="mailto:someone@example.com">
someone@example.com</a>.</p>
</footer>
Notice that NOT all links of a document should be inside a <nav> element.
The <nav> element is intended only for major block of navigation links.
Example
<nav>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/jquery/">jQuery</a>
</nav>
The <aside> element defines some content aside from the content it is placed
in (like a sidebar).
Example
<p>My family and I visited The Epcot center this summer.</p>
<aside>
<h4>Epcot Center</h4>
<p>The Epcot Center is a theme park in Disney World, Florida.</p>
</aside>
Example
<figure>
<img src="pic_trulli.jpg" alt="Trulli">
<figcaption>Fig1. - Trulli, Puglia, Italy.</figcaption>
</figure>
The <img> element defines the image, the <figcaption> element defines the
caption.
HTML5 Canvas
The HTML <canvas> element is used to draw graphics on a web page.
The graphic to the left is created with <canvas>. It shows four elements: a
red rectangle, a gradient rectangle, a multicolor rectangle, and a multicolor
text.
The HTML <canvas> element is used to draw graphics, on the fly, via JavaScript.
The <canvas> element is only a container for graphics. You must use JavaScript
to actually draw the graphics.
Canvas has several methods for drawing paths, boxes, circles, text, and adding
images.
Canvas Examples
A canvas is a rectangular area on an HTML page. By default, a canvas has no
border and no content.
Example
<canvas id="myCanvas" width="200" height="100" style="border:1px solid
#000000;">
</canvas>
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
Example
Draw a Line
<!DOCTYPE html>
<html>
<body>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.moveTo(0,0);
ctx.lineTo(200,100);
ctx.stroke();
</script>
</body>
</html>
Draw a Circle
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95, 50, 40, 0, 2 * Math.PI);
ctx.stroke();
</script>
Draw a Text
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.font = "30px Arial";
ctx.fillText("Hello World", 10, 50);
</script>
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
Stroke Text
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.font = "30px Arial";
ctx.strokeText("Hello World", 10, 50);
</script>
HTML5 SVG
What is SVG?
• SVG stands for Scalable Vector Graphics
• SVG is used to define graphics for the Web
• SVG is a W3C recommendation
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
SVG Star
<svg width="300" height="200">
<polygon points="100,10 40,198 190,78 10,78 160,198"
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;" />
</svg>
SVG is XML based, which means that every element is available within the SVG
DOM. You can attach JavaScript event handlers for an element.
Canvas SVG
• <datalist>
• <output>
Example
<form action="/action_page.php">
<input list="browsers">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
</form>
Example
Perform a calculation and show the result in an <output> element:
<form action="/action_page.php"
oninput="x.value=parseInt(a.value)+parseInt(b.value)">
0
<input type="range" id="a" name="a" value="50">
100 +
<input type="number" id="b" name="b" value="50">
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
=
<output name="x" for="a b"></output>
<br><br>
<input type="submit">
</form>
HTML Multimedia
What is Multimedia?
Multimedia comes in many different formats. It can be almost anything you can
hear or see.
Examples: Images, music, sound, videos, records, films, animations, and more.
Web pages often contain multimedia elements of different types and formats.
HTML5 Video
The HTML <video> Element
<!DOCTYPE html>
<html>
<body>
</body>
</html>
HTML5 Audio
Audio on the Web
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
Before HTML5, audio files could only be played in a browser with a plug-in (like
flash).
The HTML5 <audio> element specifies a standard way to embed audio in a web
page.
Example
<!DOCTYPE html>
<html>
<body>
<audio controls>
</audio>
</body>
</html>
The <source> element allows you to specify alternative audio files which the
browser may choose from. The browser will use the first recognized format.
The text between the <audio> and </audio> tags will only be displayed in
browsers that do not support the <audio> element.
WEB DESIGN PROGRAMMING : CHAPTER 2
(Static Webpage Development:HTML) ----JITENDRA SINGH
You can use this id, and refer to your video in the HTML code.
<html>
<body>
</iframe>
</body>
</html>