Understanding Basic HTML: A Beginner's Guide
HTML, or HyperText Markup Language, is the foundation of web development. It provides the structure and layout for web pages, allowing you to create text, images, links, forms, and more. In this beginner's guide, we'll explore the basics of HTML and how it works.
What is HTML?
HTML is a markup language used to create the structure of web pages. It consists of elements, tags, and attributes that define the content and its presentation on a webpage. HTML documents are plain text files with a .html or .htm extension.
Basic Structure of an HTML Document
An HTML document follows a specific structure:
htmlCopy code<!DOCTYPE html>
<html>
<head>
<title>Title of the Page</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
<html>
: This tag represents the root element of an HTML document and encloses all other HTML elements.<head>
: The<head>
tag contains meta-information about the document, such as the title, character set, stylesheets, and scripts.<title>
: Inside the<head>
section, the<title>
tag specifies the title of the web page, which appears in the browser's title bar or tab.<body>
: The<body>
tag contains the main content of the web page, including text, images, links, and other elements.<h1>
,<h2>
,<h3>
,<h4>
,<h5>
,<h6>
: These tags are used to create headings of different levels, with<h1>
being the largest and most important heading, and<h6>
being the smallest.<p>
: The<p>
tag is used to define paragraphs of text.
HTML Elements, Tags, and Attributes
Elements: HTML elements are the building blocks of a webpage and are enclosed in opening and closing tags. For example,
<p>
is an element used for paragraphs.Tags: Tags define the beginning and end of an element. They are enclosed in angle brackets, e.g.,
<p>
and</p>
for opening and closing a paragraph.Attributes: Attributes provide additional information about an element and are included within the opening tag. For instance, the
href
attribute in<a href="
https://example.com">Link</a>
specifies the URL for a link.
Common HTML Elements
Headings: Used for defining headings of different levels (h1 to h6).
htmlCopy code<h1>This is a Heading</h1> <h2>This is a Subheading</h2>
Paragraphs: Used for structuring text content.
htmlCopy code<p>This is a paragraph.</p>
Links: Create clickable links to other web pages.
htmlCopy code<a href="https://example.com">Click Here</a>
Images: Display images on a webpage.
htmlCopy code<img src="image.jpg" alt="Description of the image">
Italic: To make text italics , use the HTML tag <em> or <i>
<p>This is <em>italicized</em> text <i>using</i> the <em>em</em> tag.</p>
Common HTML tag
Common HTML tags are the fundamental building blocks used to structure and format content on a web page. Here are some of the most commonly used HTML tags:
<html>
: Defines the root element of an HTML document.<head>
: Contains metadata about the HTML document, such as the title and links to stylesheets.<title>
: Sets the title of the web page displayed in the browser's title bar or tab.<body>
: Contains the main content of the web page, including text, images, links, and other elements.<h1>
,<h2>
,<h3>
,<h4>
,<h5>
,<h6>
: Heading tags for defining headings of different levels (from largest<h1>
to smallest<h6>
).<p>
: Defines a paragraph of text.<a>
: Creates hyperlinks to other web pages or resources.<img>
: Inserts an image into the web page.<div>
: Defines a division or section in the document for styling purposes.<span>
: Defines a span of text for applying inline styles or scripting.<ul>
,<ol>
,<li>
: Used for creating unordered lists (<ul>
), ordered lists (<ol>
), and list items (<li>
).<table>
,<tr>
,<th>
,<td>
: Tags for creating tables and their rows, header cells, and data cells.<
form>
,<input>
,<button>
: Used for creating input forms and form elements like text fields, checkboxes, radio buttons, and buttons.<br>
: Inserts a line break.<hr>
: Creates a horizontal line or separator.
Conclusion
HTML is a fundamental language for web development, allowing you to create structured and meaningful web pages. By understanding the basic structure of HTML documents, HTML elements and tags, attributes, and comments, you can start building your own web pages and learning more advanced web development concepts.
Subscribe to my newsletter
Read articles from Chinmaya Mohanty directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by