HTML
2020/21 COMP3322 Modern Technologies on WWW
Contents
• History of HTML
• HTML Syntax and Structure of HTML
• Quick Tour of Common HTML structural Elements • HTML Validation
• HTML5 Semantic Elements
2
• •
HTML
HTML is a type of markup languages.
A markup language is simply a way of annotating a document in such a way
• to make the annotations distinct from the text content being annotated
• to indicate information about the content
This “information about content” in HTML is implemented via tags (aka elements).
•
• Now people believe that HTML documents should only focus on the structure of the document.
• Information about how the content should look (i.e. presentation) is best left to CSS.
3
Brief History of HTML
• 1991 – the first public specification of the HTML by Tim Berners-Lee • 1995 – HTML 2.0 was published by HTML Working Group under IETF • Jan 1997 – HTML 3.2 was published by W3C
• Dec 1997 – HTML 4.0 was released
• Dec 1999 – HTML 4.01 was published
• Jan 2000 – XHTML 1.0 was published, reformulation of HTML using XML
• Oct 2014 – HTML 5 was published
• Dec 2017 – HTML 5.2 was published
Source: Wikipedia
4
HTML Syntax and
Structure of HTML
HTML Syntax: Elements and Attributes
• HTML documents are composed of Web content and HTML elements.
• An HTML element can contain text, other elements, or be empty.
• It is identified in the HTML document usually by a pair of tags.
• Each HTML element gives the browser some information about the content that sits between the tags.
Opening • HTML elements can also contain attributes. An tag
HTML document
HTML Web
elements
Tag
content
HTML attribute is a name=value pair that provides more information about the HTML element.
• In XHTML, attribute values had to be enclosed in quotes; in HTML5, the quotes are optional.
Closing tag
Attributes
6
Elements and Attributes
• Tags act like a ‘container’, which give you some information (the meaning) that lies between their opening and closing tags.
• Attributes provide additional information about the contents of an element and they appear on the opening tag of the element.
Opening Tag Closing Tag
Department of Computer Science Element Name Attribute
Trailing slash
or
An example of empty element – tags are not paired and with no content HTML5 does not require empty elements to be closed
7
Elements and Attributes
• The attribute names for each element are defined in the HTML specifications.
• Some attributes are required for some elements, such as the src and alt attributes in the img element.
• An element may have several attributes applied to it, separated by spaces. Their order is not important.
• Most attributes take values.
• A value might be a number, a word, a string of text, a URL, or a
measurement, depending on the purpose of the attribute. • Some attributes just have the name without a value.
8
Nesting HTML elements
• HTML element may contain other HTML elements.
• Any elements contained within are said to be descendents of the parent
element; likewise, any given child element, may have a variety of ancestors.
• The browser is expecting a child element’s ending tag must occur before its parent’s ending tag.
9
Basic Document Structure
❶ ❷
❸
❺ ❻
❹
10
• DOCTYPE is not an HTML element
• This is a requirement imposed by HTML5 standard
• It defines the HTML version to which your page is based on, and in some cases, the Document Type Definition (DTD) that defines the specification.
11
• HTML5 does not require the use of the , , and .
• In XHTML they were required, so most web authors continue to use them.
• The element is sometimes called the root element as it contains all the other HTML elements in the document.
• The contains descriptive elements about the document
• The contains content that will be displayed by the browser.
12
• The element may contain the following elements:
•
• – Specifies an external CSS style sheet
file
•