HTML Course
HTML Course
Example Explained
● The <!DOCTYPE html> declaration defines that this document is an HTML5 document
● The <html> element is the root element of an HTML page
● 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.
● The <h1> element defines a large heading
● The <p> element defines a paragraph
What is an HTML Element?
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 contains several elements for defining text with a special meaning.
HTML Formatting Elements
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading:
HTML Paragraphs
HTML Lists
HTML lists allow web developers to group a set of related items in lists.
An unordered list starts with the <ul> tag. Each list item starts with the <li>
tag.
The list items will be marked with bullets (small black circles) by default:
Ordered HTML List
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
The <dl> tag defines the description list, the <dt> tag defines the term (name),
and the <dd> tag describes each term:
HTML Links
HTML Images
The source file (src), alternative text (alt), width, and height are provided as attributes:
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>):
HTML Attributes
HTML attributes provide additional information about HTML elements.
HTML Attributes
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes
to:
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:
The <img> tag should also contain the width and height attributes, which specify the width and
height of the image (in pixels):
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.
The style attribute is used to add styles to an element, such as color, font, size, and more.
HTML Tables
HTML tables allow web developers to arrange data into rows and columns.
Table Rows
Each table row starts with a <tr> and ends with a </tr> tag.
You can have as many rows as you like in a table; just make sure that the number of cells are the
same in each row.
Table Headers
Sometimes you want your cells to be table header cells. In those cases use the <th> tag instead of
the <td> tag:
th stands for table header
HTML tables can have cells that span over multiple rows and/or columns.
HTML Table - Colspan
To make a cell span over multiple columns, use the colspan attribute:
To make a cell span over multiple rows, use the rowspan attribute:
HTML Form
An HTML form is used to collect user input. The user input is most often sent to a server for
processing.
The HTML <form> element is used to create an HTML form for user input:
The <form> element is a container for different types of input elements, such as: text fields,
checkboxes, radio buttons, submit buttons, etc.
Text Fields
The <input type="text"> defines a single-line input field for text input.
The <label> element is useful for screen-reader users, because the screen-reader will read out
loud the label when the user focuses on the input element.
The <label> element also helps users who have difficulty clicking on very small regions (such as
radio buttons or checkboxes) - because when the user clicks the text within the <label> element,
it toggles the radio button/checkbox.
Radio Buttons
Checkboxes
Checkboxes let a user select ZERO or MORE options of a limited number of choices.
The <input type="submit"> defines a button for submitting the form data to a form-handler.
The form-handler is typically a file on the server with a script for processing input data.
HTML Video
How it Works
The controls attribute adds video controls, like play, pause, and volume.
It is a good idea to always include width and height attributes. If height and width are not set, the
page might flicker while the video loads.
The <source> element allows you to specify alternative video files which the browser may
choose from. The browser will use the first recognized format.
The text between the <video> and </video> tags will only be displayed in browsers that do not
support the <video> element.
The HTML <audio> element is used to play an audio file on a web page.
The controls attribute adds audio controls, like play, pause, and volume.
The <source> element allows you to specify alternative audio files which the browser may
choose from. The browser will use the first recognized format.
The text between the <audio> and </audio> tags will only be displayed in browsers that do not
support the <audio> element