HTML Material
HTML Material
browser. It can be assisted by technologies such as Cascading Style Sheets and scripting languages such as JavaScript.
XHTML is a term that was historically used to describe HTML documents written to conform with XML syntax rules. The
following example shows an HTML document and corresponding “XHTML” document, and the accompanying HTTP Content-
Type headers they should be served with.
HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major
HTML version that is a World Wide Web Consortium recommendation. The current specification is known as the HTML Living
Standard.
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Example Explained
The <!DOCTYPE html> declaration defines that this document is an HTML5 document
The <head> element contains meta information about the HTML page
The <title> element specifies a title for the HTML page (which is shown in the browser’s title bar or in the page’s tab)
The <body> element defines the document’s body, and is a container for all the visible contents, such as headings, paragraphs,
images, hyperlinks, tables, lists, etc.
An HTML element is defined by a start tag, some content, and an end tag:
The HTML element is everything from the start tag to the end tag:
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Documents:
All HTML documents must start with a document type declaration: <!DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>.
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
The <!DOCTYPE> declaration represents the document type, and helps browsers to display web pages correctly.
It must only appear once, at the top of the page (before any HTML tags).
<!DOCTYPE html>
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading:
Example
<h1>This is heading 1</h1>
HTML Paragraphs
Example
<p>This is a paragraph.</p>
HTML Links
Example
HTML Images
The source file (src), alternative text (alt), width, and height are provided as attributes:
Example
HTML Elements
The HTML element is everything from the start tag to the end tag:
HTML elements can be nested (this means that elements can contain other elements).
The following example contains four HTML elements (<html>, <body>, <h1> and <p>):
Example
<!DOCTYPE html>
<html>
<body>
</html>
Html attributes:
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to:
Example
The <img> tag is used to embed an image in an HTML page. The src attribute specifies the path to the image to be displayed:
Example
The <img> tag should also contain the width and height attributes, which specify the width and height of the image (in pixels):
Example
The required alt attribute for the <img> tag specifies an alternate text for an image, if the image for some reason cannot be
displayed. This can be due to a slow connection, or an error in the src attribute, or if the user uses a screen reader.
Example
The style attribute is used to add styles to an element, such as color, font, size, and more.
Example
The value of the title attribute will be displayed as a tooltip when you mouse over the element:
Example
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading.
Example
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>