HTML
What is HTML: Syntax, Usage, and Examples
HTML (HyperText Markup Language) is the standard language for creating web pages. It structures content using elements enclosed in tags, defining headings, paragraphs, links, images, and other components. Web browsers read HTML files and render them as interactive, visual pages. Whether you're building a personal blog, an online store, or a corporate website, you rely on HTML to define its structure.
How to Use HTML
HTML uses tags enclosed in angle brackets (< >
) to mark elements on a page. These tags tell the browser how to interpret and display the content. Most HTML tags come in pairs, with an opening tag (<p>
) and a closing tag (</p>
).
Basic HTML Structure
Every HTML document follows a common structure. Here’s a simple example:
<!DOCTYPE html>
<html>
<head>
<title>My First HTML Page</title>
</head>
<body>
<h1>Welcome to HTML</h1>
<p>This is a paragraph explaining how HTML works.</p>
</body>
</html>
<!DOCTYPE html>
declares the document as HTML5.<html>
is the root element containing everything on the page.<head>
holds metadata like the page title and styles.<body>
contains visible content like headings, paragraphs, and images.
When to Use HTML
HTML is essential whenever you want to create or modify a web page. It works for:
1. Structuring Content
HTML organizes content into logical sections. You use different tags for headings (<h1> - <h6>
), paragraphs (<p>
), and lists (<ul>
, <ol>
).
2. Linking Pages Together
HTML allows you to connect pages using hyperlinks. Whether you're building a small site or a large web application, you need links to navigate between pages.
3. Embedding Media
You can insert images, videos, and audio using HTML. The <img>
, <video>
, and <audio>
tags handle media files, making pages visually appealing.
4. Creating Forms
Forms let users input data, such as login credentials, search queries, or feedback. HTML form elements include text fields, radio buttons, checkboxes, and dropdowns.
5. Interacting with CSS and JavaScript
HTML provides the foundation for styling with CSS and adding interactivity with JavaScript. A page might look dull with plain HTML, but CSS enhances its appearance, while JavaScript brings it to life.
Examples of HTML
Adding an Image
<img src="sunset.jpg" alt="A beautiful sunset over the ocean">
src
specifies the image file location.alt
provides alternative text for accessibility and search engines.
Creating a Link
<a href="https://www.example.com">Visit Example</a>
Clicking this link directs users to "https://www.example.com".
Making a List
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<ul>
creates an unordered list with bullet points.<li>
defines each list item.
Learn More About HTML
What is HTML Used For?
HTML is the foundation of every web page. It helps structure and present content while supporting modern features like responsive design, multimedia embedding, and search engine optimization. You use HTML to:
- Organize text, images, and multimedia.
- Connect different web pages via hyperlinks.
- Enhance SEO by using semantic elements.
- Create web applications with form inputs and scripts.
What is the HTML Tag?
An HTML tag is a keyword enclosed in angle brackets (< >
). Tags usually come in pairs—an opening tag (<p>
) and a closing tag (</p>
). The closing tag has a forward slash (/
) before the tag name.
Here are some common tags:
<h1>
to<h6>
– Headings<p>
– Paragraphs<a>
– Links<img>
– Images<table>
– Tables
What is HTML Code?
HTML code is the raw markup language that browsers interpret.
<!DOCTYPE html>
<html>
<head>
<title>HTML Code Example</title>
</head>
<body>
<p>This is a sample HTML code snippet.</p>
</body>
</html>
Web browsers process this code and display the structured content.
What is an HTML File?
An HTML file is a document containing HTML code. It has a .html
or .htm
extension and can be opened in any web browser.
What is an Interstitial HTML?
An interstitial HTML page appears before the main content loads. Examples include:
- Ads before a webpage fully loads.
- Age verification pop-ups.
- Login prompts before accessing restricted areas.
HTML Forms
Forms let users submit data.
<form action="submit.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<button type="submit">Submit</button>
</form>
<label>
describes an input field.<input>
captures user data.<button>
submits the form.
Tables in HTML
Tables organize data into rows and columns.
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Alice</td>
<td>30</td>
</tr>
</table>
<th>
represents a table header.<td>
holds table data.
HTML and CSS
CSS styles HTML pages.
<style>
p {
color: blue;
font-size: 18px;
}
</style>
<p>This is a styled paragraph.</p>
- The
<style>
block defines CSS rules inside HTML. - The
color
property sets text color. font-size
adjusts text size.
HTML and JavaScript
JavaScript adds interactivity.
<button onclick="alert('Hello!')">Click me</button>
Clicking the button triggers a pop-up message.
HTML5 Features
HTML5 introduced new elements, including:
<article>
– Represents a self-contained section.<section>
– Defines a content section.<video>
– Embeds video.<audio>
– Embeds audio.
SEO and HTML
Search engines analyze HTML structure to understand page content. Proper use of headings (<h1>
to <h6>
), meta descriptions, and alt attributes helps with ranking.
Accessibility and HTML
Accessible HTML ensures that all users, including those with disabilities, can navigate content.
- Use
alt
attributes for images. - Structure content with headings.
- Provide labels for form inputs.
HTML Best Practices
- Use semantic tags (
<header>
,<nav>
,<footer>
). - Write clean, well-indented code.
- Optimize images for faster loading.
- Use external stylesheets instead of inline styles.
HTML is the backbone of web development. You use it to structure content, link pages, embed multimedia, and work with CSS and JavaScript to create interactive experiences. Mastering HTML is the first step toward becoming a skilled web developer.
Sign up or download Mimo from the App Store or Google Play to enhance your programming skills and prepare for a career in tech.