HTML Tutorial
2. Getting
started with HTML
[this page | pdf | back links]
As
explained in HTML
and other markup languages, there are various ‘dialects’ of HTML. This
means that some examples of HTML may be understood by some browsers but
rejected by others. The following text, when put into a text editor and saved
with a .htm file extension, will usually successfully render a web page that says
“Hello World (using HTML)” if the file is viewed in Microsoft Edge. Note that
HTML largely ignores page breaks; if you want to include a page break in the
text shown to the user then you need to add a <br>
element (or a <br /> element
if you are using XHTML,
which is a modern variant of HTML that involves a cross between classic HTML
and XML).
<html>
<body>
Hello World (using HTML)
</body>
</html>
However,
strictly speaking an HTML document is supposed to start with a document type
declaration, along the lines of e.g. <!DOCTYPE
html> and a header along the lines of e.g. <head><title>Document title</title></head>. So, a
better way to create the page shown above is as follows. We’ve added a comment
into the document, using HTML comment tags. Comments are not displayed by the
browser but can help to document the HTML source text.
<!DOCTYPE html>
<html>
<head>
<title>My Document</title>
</head>
<!-- Only the text in the body will appear in the browser
-->
<body>
Hello World (Using HTML)
</body>
</html>
Often,
the <html> element also
includes a lang attribute, as
this can be important for accessibility applications (such as screen readers)
and for search engines. With the lang
attribute, the first two letters specify the language. If the language comes in
various dialects then two more letters specify the dialect, e.g.:
NAVIGATION LINKS
Contents | Prev | Next | HTML