Introduction To Web Programming
Introduction To Web Programming
blog
Web Programming
HTML
CSS JavaScript
Edge
Firefox
Opera
Safari
Chrome
The Web Browser
Web Pages Examples
4
Web Pages
Examples
https://www.halvorsen.blog
The Web Programming Triangle
HTML Use HTML to define the
content of web pages
Web
Programming
CSS JavaScript
Use CSS to specify the layout of web pages Use JavaScript to program
the behavior of web pages
Web Programming
JavaScript CSS
HTML ASP.NET
IIS XML
Web Services SQL
Web API
JQuery
PHP AJAX
Basic Web Programming
• HTML
• CSS
• JavaScript
LM
Server
Web
JavaScript
Web Architecture
Web Browser
Client
ASP.NET PHP
Server-side
Request
Database
The code runs on the server and converted to Web Page (HTML)
HTML before sending to client (Web Browser)
Consortium <body>
Content of the document......
</body>
</html>
14
<!DOCTYPE html>
<html> HTML Code
<body>
</body>
</html>
Web Browser
15
HTML Page Structure
<!DOCTYPE html>
<html>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is another
paragraph.</p>
</body>
</html> 16
HTML Editors
Professional HTML editors: These are WYSIWYG Editors
• Adobe Dreamweaver where you can see the resulting
Web page instantly
• CoffeeCup HTML Editor
• ...
For the simple examples in this Tutorial you may only
need Notepad (Windows) or TextEdit (Mac)
Hyperlinks <html>
<body>
<h1>This is a heading</h1>
</body>
</html>
<body>
<h1>This is a heading</h1>
</body>
</html>
Hyperlink:
HTML Tags
<a href="http://www.google.com">This is a link to Google</a>
once }
text-align: center;
p {
font-family: "Times New Roman";
font-size: 20px;
}
Why CSS is needed
• HTML was never intended to contain tags for formatting a document.
• HTML was intended to define the content of a document, like:
• <h1>This is a heading</h1>
• <p>This is a paragraph.</p>
• When tags like <font>, and color attributes were added to the HTML 3.2
specification, it started a nightmare for web developers. Development of
large web sites, where fonts and color information were added to every
single page, became a long and expensive process.
• To solve this problem, the World Wide Web Consortium (W3C) created
CSS.
• In HTML 4.0, all formatting could be removed from the HTML document,
and stored in a separate CSS file.
• All browsers support CSS today.
HTML + CSS Example
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #d0e4fe;
}
h1 {
color: orange;
text-align: center;
}
p {
font-family: "Times New Roman";
font-size: 20px;
}
</style>
</head>
<body>
Exercises: Create this Code in e.g., NotePad or
Visual Studio Code and Save the File as .html.
<h1>My First CSS Example</h1>
<p>This is a paragraph.</p> Then Open the File in a Web Browser (just
</body>
double-click on the file).
</html> Change color, etc. and see what happens.
CSS Syntax
A CSS declaration always ends with a semicolon, and declaration groups are
surrounded by curly braces, e.g.:
p {color:red;text-align:center;}
.center {
CSS Classes } p.center {
text-align: center;
text-align: center; color: red;
color: red; }
}
<!DOCTYPE html>
<html>
<head>
<style>
<!DOCTYPE html> p.center {
<html> text-align: center;
<head> color: red;
<style> }
.center {
</style>
text-align: center;
color: red; </head>
} <body>
</style>
</head> <h1 class="center">My Heading</h1>
<body> <p class="center">My Paragraph</p>
h1 {
color: navy;
margin-left: 20px;
} Exercise: Try this Example
Text Color
body {
CSS Properties
color: blue; Background Color
}
Text Alignment
h1 {
body {
text-align: center; background-color: lightblue;
h1 { } }
color: #00ff00;
} p.date {
text-align: right;
h2 { } Text Size
color: rgb(255,0,0);
p.main { h1 {
}
text-align: justify; font-size: 40px;
} }
Text Font
p { h2 {
font-family: "Times New Roman", Times, serif; font-size: 30px;
} }
p {
Exercise: Create a Style Sheet (.CSS) and a font-size: 14px;
HTML page where you use these Properties } 30
CSS Example
http://www.w3schools.com/css/demo_default.htm
Exercise: Open this Example and see how different styles totally
changes the display and layout of a HTML page
JavaScript
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello JavaScript!";
}
</script>
</body>
</html>
<!DOCTYPE html>
JavaScript Example 2
<html>
<body>
<p id="demo"></p>
<script>
function myFunction() {
var x, text;
x = document.getElementById("numb").value;
</body>
</html>
JavaScript Comments
// Change heading:
document.getElementById("myH").innerHTML = "My First Page";
// Change paragraph:
document.getElementById("myP").innerHTML = "My first paragraph.";
var x = 5; // Declare x, give it the value of 5
var y = x + 2; // Declare y, give it the value of x + 2
/*
The code below will change the heading with id = "myH” and the paragraph with id = "myP” in my web page:
*/
document.getElementById("myH").innerHTML = "My First Page";
document.getElementById("myP").innerHTML = "My first paragraph.";
/*
document.getElementById("myH").innerHTML = "My First Page";
document.getElementById("myP").innerHTML = "My first paragraph.";
*/
JavaScript Placement
• You can place any number of scripts in an HTML
document. Scripts can be placed in the <body>, or in
the <head> section of an HTML page, or in both.
• It is a good idea to place scripts at the bottom of the
<body> element. This improves page load, because
HTML loading is not blocked by scripts loading.
• Scripts can also be placed in external files. External
scripts are practical when the same code is used in
many different web pages. JavaScript files have the
file extension .js.
Server
Web
Hans-Petter Halvorsen, M.Sc.
Web Server
The term web server can refer to either the hardware (the computer) or the software (the
computer application) that helps to deliver web content that can be accessed through the
Internet.
The most common use of web servers is to host websites, but there are other uses such as
gaming, data storage or running enterprise applications.
• IIS - Internet Information Services
– Microsoft Windows
• Apache Web Server
– Open Source
– Cross-platform: UNIX, Linux, OS X, Windows, ...
• Nginx (pronounced "engine x") - Has become very popular latly
• GWS (Google Web Server)
• ...
Web Server Popularity
http://www.digi.no/921119/under-halvparten-bruker-apache
Internet Information Services (IIS)
• IIS – Internet Information Services
• Web Server that host the Web Pages/Web Site
• Make sure to have the IIS installed with ASP.NET sub components
</body>
</html>
IIS Deployment
...
References
• HTML Tutorial:
http://www.w3schools.com/html
• CSS Tutorial: http://www.w3schools.com/css
• JavaScript Tutorial:
http://www.w3schools.com/js
Hans-Petter Halvorsen
University of Southeast Norway
www.usn.no
E-mail: hans.p.halvorsen@usn.no
Web: https://www.halvorsen.blog