HTML (HyperText Markup Language) is the standard markup language used to create web pages. Understanding HTML elements, attributes, and tags is essential for web development. This reference guide provides detailed information about HTML components, their usage, and best practices.
HTML elements are the building blocks of web pages. They represent different types of content, such as headings, paragraphs, links, images, and more. Here are some common HTML elements:
Element | Description | Example |
---|---|---|
<h1> to <h6> | Defines HTML headings. <h1> is the highest (most important) level, and <h6> is the lowest level. |
Try yourself
|
<p> | Defines a paragraph. |
Try yourself
|
<a> | Defines a hyperlink. |
Try yourself
|
<img> | Defines an image. |
Try yourself
|
<ul><li> | Defines an unordered list and list items. |
Try yourself
|
<table> | Defines a table. |
Try yourself
|
HTML attributes provide additional information about elements. They are always included in the opening tag and usually come in name/value pairs like name="value". Here are some common HTML attributes:
Attribute | Description | Example |
---|---|---|
id | Specifies a unique id for an HTML element. |
Try yourself
|
class | Specifies one or more class names for an HTML element (used for CSS and JavaScript). |
Try yourself
|
src | Specifies the source file for an image, script, or iframe. |
Try yourself
|
href | Specifies the URL for a link. |
Try yourself
|
alt | Provides alternative text for an image. |
Try yourself
|
HTML tags are used to create HTML elements. Tags are enclosed in angle brackets like <tagname>. Most HTML tags come in pairs, with an opening tag and a closing tag. Here are some important HTML tags:
Tag | Description | Example |
---|---|---|
<div></div> | Defines a division or a section in an HTML document. |
Try yourself
|
<span></span> | Defines a section in a document. |
Try yourself
|
<header></header> | Defines a header for a document or a section. |
Try yourself
|
<footer></footer> | Defines a footer for a document or a section. |
Try yourself
|
<main></main> | Specifies the main content of a document. |
Try yourself
|