An HTML tag acts as a container for content or other HTML tags.
Tags are words enclosed within <
and >
angle brackets. They serve as keywords that instruct the web browser on how to format and display the content.
In HTML, tags can be broadly categorized into two types:
These are tags that come in pairs, consisting of an opening tag and a corresponding closing tag.
The content goes between these two tags.
<
and ends with >
. For example, <p>
.<
but includes a forward slash /
before the tag name, and ends with >
. For example, </p>
.<p>This is a paragraph.</p>
<h1>This is a heading.</h1>
<
and ends with />
(though the /
is optional in HTML5). For example, <img />
or <br>
.<br/>
<hr/>
<img src="image.jpg" alt="An example image"/>
Here are some commonly used tags in HTML. These are the only tags used 70% of the time:
<!DOCTYPE html>
: Specifies the document type.<html>
: Encloses the entire HTML document.<head>
: Contains meta-information and links to scripts and stylesheets.<body>
: Contains the content of the web page.<title>
: Sets the title of the web page.<meta>
: Provides metadata such as character set, author, and viewport settings.<link>
: Links external resources like stylesheets.<header>
: Header section.<footer>
: Footer section.<article>
: Article.<section>
: Section.<nav>
: Navigation.<aside>
: Sidebar content.<h1>
, <h2>
, <h3>
, <h4>
, <h5>
, <h6>
: Headings<p>
: Paragraph.<pre>
: Pre-defined text.<b>
: Bold Text.<i>
: Italics Text.<u>
: Underline Text.<strike>
: Strike-through text.<big>
: Big Text.<small>
: Small Text.<sup>
: Superscript [ A2] Text.<sub>
: Subscript [O 2 ] Text.<marquee>
: Scrolling piece of text or an image.<br>
: Single Line-break.<hr>
: Horizontal rule.<a>
: Anchor (used for links).<img>
: Image.<audio>
: Audio content.<video>
: Video content.<iframe>
: inline frames in webpage.<ul>
: Unordered list.<ol>
: Ordered list.<li>
: List item.<dl>
: Description list
<dt>
: Defines the term (name)<dd>
: Describes each term.<table>
: Table.
<thead>
: Table header group.<tr>
: Table row.<th>
: Table header cell.<td>
: Table data cell.<tbody>
: Table body group.<tfoot>
: Table footer group.<form>
: Form.<input>
: Input field.<textarea>
: Text area.<button>
: Button.<select>
: Dropdown list.<option>
: Options within a <select>
or <datalist>
.