Professional Documents
Culture Documents
beatsigner.com
2 December 2005
Hypertext Markup Language (HTML)
▪ HTML is an application of the Standard Generalized
Markup Language (SGML)
▪ simple human-readable markup language with a number of
markup tags that can be manipulated by any text editor
▪ Various markup tags to define the structure and
presentation of a HTML document (webpage)
▪ root element (<html>), header (<head>), body (<body>) and
title (<title>)
▪ headings (<h1>, ... <h6>) and paragraphs (<p>)
▪ tables (<table>, <tr> and <td>) and lists (<ol>, <ul> and <li>)
▪ images (<img>)
▪ w3schools provides a detailed list of tags
▪ https://www.w3schools.com/tags/
October 15, 2021 Beat Signer - Department of Computer Science - bsigner@vub.ac.be 2
Hypertext Markup Language (HTML) ...
▪ Tags can be nested and attributes (key/value pairs) can
be added to a tag
▪ HTML documents are transformed into a Document
Object Model (DOM) by the browser
▪ tree of elements (and attributes) with textual content
▪ HTML DOM defines objects and properties for HTML elements
- document node, element nodes, text nodes, attribute nodes
and comment nodes
▪ standard to create, read, update and delete HTML elements
▪ Hyperlinks to connect different HTML documents
▪ only unidirectional embedded hyperlinks are supported
head body
title h1 p p …
Working Draft
Web Open
Web HTML +
Font
Storage RDFa
W3C Working Group Note JavaScript
RDFa
Non-W3C Specification
WebGL Web
Messaging
Geo
Canvas Web Location
2D Sockets
Battery
Status
API HTML
Touch
▪ Simplifies implementation Markup Drag
Audio Events
and
Video
Drop
of cross-platform applications Fullscreen
Web Timing
Micro Control
Workers
▪ Standard way for accessing XmlHTTP
data
Request Screen
specific functionality Orientation
File API
▪ No need for plug-in installation Contacts
Media Indexed API
Capure Database
based on https://en.wikipedia.org/wiki/HTML5#/
https://www.devsaran.com/blog/10-best-programming-languages-2020-you-should-know
Internet Explorer
Trident Engine
WorldWideWeb
Firefox
Mozilla
Gecko Engine
WebKit Engine
Safari
Chrome
https://en.wikipedia.org/wiki/File:Timeline_of_web_browsers.svg
in HTML pages
▪ element has methods, properties and events
▪ no external plug-in (e.g. Adobe Flash) required anymore
▪ e.g. in early 2015 YouTube switched from Flash to HTML5 video
as the default
▪ Multiple video formats are supported
▪ MP4, WebM and Ogg
<video width="640" height="480" controls="controls" autoplay="autoplay">
<source src="bullhead.mp4" type="video/mp4" />
The video tag is not supported by your browser!
</video>
in HTML pages
▪ element has methods, properties and events
<audio controls="controls">
<source src="intro.mp3" type="audio/mpeg" />
The audio tag is not supported by your browser!
</audio>
<script type=“application/javascript">
var canvas = document.getElementById("drawingArea");
var context = canvas.getContext("2d");
context.fillStyle = "#0000FF";
context.fillRect(50,50,100,50);
context.moveTo(0,0);
context.lineTo(200,200);
context.stroke();
</script>
▪ resolution independent
▪ define graphics in XML format (embeddable in HTML)
▪ good support for animations (declarative description)
▪ full control over each element via the SVG DOM API
▪ On the other hand, Canvas 2D offers better performance
<!DOCTYPE html>
<html lang="en">
<head>...</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg">
<circle id="myCircle" cx="50" cy="50" r="100" fill="blue" />
</svg>
</body>
</html>
<script>
if (localStorage.counter) {
localStorage.counter = Number(localStorage.counter) + 1;
}
else {
localStorage.counter = 1;
}
document.write("Total of " + localStorage.counter + " visits");
</script>
<head>
// style sheet information for the div elements
<script>
function drag(event) {
event.dataTransfer.setData("text/plain", event.target.id);
}
function drop(event) {
event.preventDefault(); // avoid default behaviour of opening as link
var data=event.dataTransfer.getData("text/plain");
event.target.appendChild(document.getElementById(data));
}
function allowDrop(event) {
event.preventDefault();
}
</script>
</head>
function handle(e) {
// process message from the web worker
}
worker.postMessage("Hello worker!");
</script>
socket.onmessage = function(e) {
var message = JSON.parse(e.data));
alert("Message received.");
...
};
socket.send("Hellow World");
// connection stays open and server can send multiple things
...
socket.close();
</script>
function showError() {
alert("Your current position cannot be computed!");
}
navigator.geolocation.getCurrentPosition(showPosition, showError,
{timeout:10000});
▪ offline browsing where users can use the web application while
they are offline
▪ increased performance due to cache hits and reduced server load
▪ Managed via a cache manifest (on every page)
<!DOCTYPE html>
<html lang="en" manifest="myApp.appcache">...</html>
CACHE MANIFEST
CACHE:
index.html
default.js
NETWORK:
dynamic.js
FALLBACK:
time.js fallback-time.js
#version 3
▪ portrait-primary, portrait-secondary,
landscape-primary or landscape-secondary
// add a listener to react to changes of screen orientation
screen.orientation.addEventListener("change", function () {
console.log("The orientation of the screen is: " + screen.orientation);
});
of a page
▪ we can adapt behaviour if a page is not visible (e.g. minimised)
- change update frequency (e.g. checking for emails) to save resources
- pause video or game
- do not charge for ads
function handle() {
if (document.hidden) {
video.pause();
} else {
video.play();
}
}
hosting device
▪ e.g. to reduce battery drain when the battery is low
var battery = navigator.battery;
console.log("Battery level: " + Math.floor(battery.level * 100) + "%");
console.log("Device is " + (battery.charging ? "charging" : "discharging");
console.log("Battery charged in " + battery.chargingTime + "s");
console.log("Battery empty in " + battery.dischargingTime + "s");
battery.onlevelchange = function() {
...
}
var options = {
body: "This is the body of my message",
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhE"
};
▪ HTML Tutorial
▪ https://www.w3schools.com/html/
2 December 2005