Introduction To HTML5
Introduction To HTML5
HTML5
HTML (Hypertext Markup Language) uses a markup system composed of
elements which represent specific content.
Markup means that with HTML you declare what is presented to a viewer, not
how it is presented.
An element usually consists of an opening tag, a closing tag which contain the
element's name surrounded by angle brackets, and the content in between:
<element_name>...content...</element_name>
There are some HTML elements that don't have a closing tag or any contents.
These are called void elements.
Void elements include <img>, <meta>, <link> and <input>.
Element names can be thought of as descriptive keywords for the content
they contain, such as video, audio, table, footer.
A HTML page may consist of potentially hundreds of elements which are then
read by a web browser, interpreted and rendered into human readable or
audible content on the screen.
Elements: video, audio, table, footer
Tags: <video>, <audio>, <table>, <footer>, </html>, </body>
HTML files can be created using any text editor. The files must be saved with a .html or
.htm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello!</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is a simple paragraph.</p>
</body>
</html>
<!DOCTYPE> Defines the HTML version used in the document. In this case it is
HTML5.
<html>
Opens the page. No markup should come after the closing tag (</html>). The lang
attribute declares the primary language of the page using the ISO language codes
(en for English).
See the Content Language topic for more information.
<head>
Opens the head section, which does not appear in the main browser window but
mainly contains information about the HTML document, called metadata. It can also
contain imports from external stylesheets and scripts. The closing tag is </head>.
<meta>
Gives the browser some metadata about the document. The charset attribute declares
the character encoding.
Modern HTML documents should always use UTF-8, even though it is not a
requirement.
In HTML, the <meta> tag does not require a closing tag.
<title> The title of the page. Text written between this opening and the closing tag
(</title>) will be displayed on the tab of the page or in the title bar of the browser.
<body> Opens the part of the document displayed to users, i.e. all the visible or
audible content of a page. No content should be added after the closing tag </body>.
History of HTML
<!DOCTYPE html>
Just 15 characters!
The DOCTYPE tells the browser which type and version of document to
expect. This should be the last time the DOCTYPE is ever changed. From
now on, all future versions of HTML will use this same simplified declaration.
The <html> Element
This is what the <html> element looked like in XHTML:
<html lang="en">
The lang attribute in the <html> element declares which language the page
content is in. Though not strictly required, it should always be specified, as it
can assist search engines and screen readers.
Each of the world’s major languages has a two-character code, e.g. Spanish = "es",
French = "fr", German = "de", Chinese = "zh", Arabic = "ar".
The <head> Section
Here is a typical XHTML <head> section:
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<title>My First XHTML Page</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<head>
<meta charset="utf-8">
<title>My First HTML5 Page</title>
<link rel="stylesheet" href="style.css">
</head>
Notice the simplified character set declaration, the shorter CSS stylesheet link
text, and the removal of the trailing slashes for these two lines.
Basic HTML5 Web Page
Putting the prior sections together, and now adding the <body> section and
closing tags, we have our first complete web page in HTML5:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My First HTML5 Page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>HTML5 is fun!</p>
</body>
</html>
Even though we used HTML5, the page looks exactly the same in a web
browser as it would in XHTML. Without looking at the source code, web
visitors will not know which version of HTML the page was created with.