Introduction to HTML5
HTML5 is the latest version of the Hypertext Markup Language used for creating web pages. It is the foundation of the web and is used to structure and present content on the internet. HTML5 is the most widely used markup language and is supported by all modern web browsers. In this tutorial, we will cover the basics of HTML5 and how to use it to create a simple web page.
Setting Up the HTML Document
Before we start writing our HTML code, we need to set up the basic structure of our document. This is done by using the
<!DOCTYPE html> declaration, which tells the browser that we are using HTML5. This declaration should be placed at the very beginning of our HTML document, before the
Next, we need to create the
<html> tag, which is the root element of our HTML document. Inside this tag, we will have two main sections - the
<head> and the
<head> section contains information about the document, such as the page title, links to external stylesheets, and metadata. The
<body> section contains the actual content of the page that will be displayed to the user.
Our HTML document should look like this:
HTML Document Structure
HTML documents are made up of a hierarchy of elements, also known as tags. These elements are used to define the structure and content of a web page. Each element has a specific purpose and can contain other elements and content.
Let's take a look at the basic structure of an HTML element:
<tagname> content </tagname>
<tagname> is the name of the element, and the content is the information that will be displayed on the page. Some elements are self-closing, which means they do not have a closing tag. These elements are written as
HTML elements can also have attributes, which provide additional information about the element. Attributes are always specified in the start tag and are written in the format
attribute="value". For example, the
<a> element is used to create a hyperlink, and it has an
href attribute that specifies the URL of the page it links to.
Let's take a look at an example of an HTML element with attributes:
<a href="https://www.example.com">Link to Example</a>
Headings and Paragraphs
Headings and paragraphs are two of the most commonly used elements in HTML. Headings are used to define the headings of a page, while paragraphs are used to define blocks of text.
There are six levels of headings in HTML, from