HTML Basic Coding & Tags – Today We will learn HTML Basic.
HTML (HyperText Markup Language) is the standard markup language used to create web pages. Here’s a basic introduction to HTML coding and some of the fundamental tags used to structure and present content on the web.
Basic Structure of an HTML Document
An HTML document has a defined structure with specific tags that enclose different parts of the content:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
<a href="https://www.example.com">This is a link</a>
</body>
</html>
Fundamental HTML Tags
Here are some of the basic tags used in HTML:
<!DOCTYPE html>
: Declares the document type and version of HTML.<html>
: The root element that encloses all the HTML content.<head>
: Contains meta-information about the document, such as the title and links to stylesheets.<title>
: Sets the title of the webpage, which appears in the browser tab.<body>
: Contains the content of the HTML document, such as text, images, links, etc.<h1>
to<h6>
: Heading tags, with<h1>
being the highest level and<h6>
the lowest.<p>
: Paragraph tag for blocks of text.<a>
: Anchor tag for creating hyperlinks. Thehref
attribute specifies the URL of the link.<img>
: Image tag for embedding images. Thesrc
attribute specifies the path to the image file, andalt
provides alternative text.<ul>
and<ol>
: Unordered and ordered lists, respectively. List items are enclosed in<li>
tags.<div>
: Division tag used as a container for other elements. Useful for CSS styling and layout.<span>
: Inline container used to wrap text for styling purposes without introducing a line break.<table>
,<tr>
,<td>
: Tags for creating tables.<table>
is the container,<tr>
defines a table row, and<td>
defines a table cell.
Example of Basic HTML Tags in Use
Here’s an example of how these tags can be combined in a simple HTML document:
<!DOCTYPE html>
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1>Welcome to My Webpage</h1>
<p>This is a paragraph with some <strong>bold</strong> and <em>italic</em> text.</p>
<h2>My Favorite Websites</h2>
<ul>
<li><a href="https://www.example.com">Example</a></li>
<li><a href="https://www.google.com">Google</a></li>
<li><a href="https://www.wikipedia.org">Wikipedia</a></li>
</ul>
<h2>Images</h2>
<img src="image.jpg" alt="Description of the image">
<h2>Table</h2>
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
</body>
</html>
Self-Closing Tags
Some HTML tags do not require a closing tag. These are known as self-closing tags. Examples include:
<img>
: Embeds an image.<br>
: Inserts a line break.<hr>
: Inserts a horizontal rule (a line).
Attributes
HTML tags can have attributes that provide additional information about the elements. Attributes are always included in the opening tag and usually come in name/value pairs like this: name="value"
. Common attributes include:
href
: Specifies the URL for an anchor tag.src
: Specifies the source file for an image tag.alt
: Provides alternative text for an image.title
: Adds a tooltip for an element.id
: Assigns a unique identifier to an element.class
: Assigns one or more class names to an element for CSS styling.
Understanding these basic concepts and tags is essential for creating and working with HTML documents.