Basic HTML Table of Contents
Basic HTML Table of Contents
Introduction to HTML
What is HTML?
HTML, or HyperText Markup Language, is the standard language used to create and
structure content on the web. It is a markup language that uses a series of elements to
define the structure and presentation of web pages. HTML is the backbone of web
development, providing the foundational structure for all web content.
History of HTML
HTML was first proposed by Tim Berners-Lee in 1991 as a way to create and share
documents over the internet. The first version, HTML 1.0, was very basic, with only a
few tags. Over the years, HTML has evolved significantly, with major updates like
HTML4 and HTML5 introducing new elements and features. HTML5, released in
2014, brought significant enhancements, including new semantic elements, multimedia
support, and APIs.
Every HTML document starts with a basic structure that includes the following
elements:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to My Web Page</h1>
<p>This is a paragraph of text.</p>
</body>
</html>
- `<!DOCTYPE html>`: This declaration defines the document type and version of
HTML being used which is HTML5.
- `<html>`: The root element that wraps all the content on the page.
- `<head>`: Contains meta-information about the document, such as the title, links
to stylesheets, and scripts.
- `<title>`: Sets the title of the web page, which appears in the browser tab.
- `<body>`: Contains the content that is displayed on the web page.
HTML element
<p>This is a paragraph.</p>
Here, `<p>` is the opening tag, `</p>` is the closing tag, and "This is a paragraph."
is the content.
HTML Attributes
Attributes provide additional information about elements. They are specified within
the opening tag and consist of a name and a value. For example:
HTML Comments
Comments are non-executable notes within the code, useful for documentation and
debugging. They are enclosed within `<!--` and `-->`. For example:
<!-- This is a comment -->
Text Formatting
Headings (`<h1>` to `<h6>`)
Headings are used to structure content hierarchically, with `<h1>` being the most
important and `<h6>` the least. For example:
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
```
Paragraphs (`<p>`)
Paragraphs are used to group related text content. For example:
These elements are used to emphasize text. `<b>` and `<strong>` make text bold,
while `<i>` and `<em>` make text italic. For example:
<b>Bold text</b>
<strong>Strong text</strong>
<i>Italic text</i>
<em>Emphasized text</em>
```
These elements are used for mathematical notations and chemical formulas. For
example:
<p>E=mc<sup>2</sup></p>
<p>H<sub>2</sub>O</p>
`<br>` inserts a line break, while `<hr>` adds a horizontal line. For example:
The `<a>` tag is used to create hyperlinks, allowing users to navigate between
pages. For example:
These attributes define where the linked content will open. For example:
<a href="https://www.example.com" target="_blank">Visit
Example</a>
```
Bookmark Links
These links allow users to jump to specific sections within a page. For example:
```
The `<img>` tag is used to embed images in a web page. For example:
```
These attributes specify the image source, alternative text, and dimensions.
These elements allow embedding of video and audio content. For example:
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
```
Lists
Unordered Lists (`<ul>`)
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
```
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
List Items (`<li>`)
Lists used for defining terms and their descriptions. For example:
<dl>
<dt>Term 1</dt>
<dd>Description 1</dd>
<dt>Term 2</dt>
<dd>Description 2</dd>
</dl>
```
Tables
Tables are used to organize data in rows and columns. For example:
<table>
<tr>
</tr>
<tr>
</tr>
</table>
Table Headers (`<th>`)
```
```
Forms
Form Structure (`<form>`)
```
Various types of input fields, such as text, radio buttons, and checkboxes. For
example:
```
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
</select>
```
Textarea (`<textarea>`)
```
```
Semantic HTML
Semantic elements provide meaning to the structure of content, improving
accessibility and SEO. Common Semantic Elements (`<header>`, `<footer>`,
`<nav>`, `<article>`, `<section>`, `<aside>`)
<header>
<h1>My Website</h1>
</header>
<nav>
<a href="/home">Home</a>
<a href="/about">About</a>
</nav>
<article>
<h2>Article Title</h2>
<p>Article content...</p>
</article>
<aside>
<h3>Related Links</h3>
<a href="/link1">Link 1</a>
<a href="/link2">Link 2</a>
</aside>
<footer>
<p>© 2023 My Website</p>
</footer>
```
HTML5 Features
```
<script>
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
console.log("Geolocation is not supported by this
browser.");
}
</script>
```
The title of the web page, displayed in the browser tab. For example:
```
Metadata about the document, such as character encoding and description. For
example:
<meta charset="UTF-8"> UTF-8 covers almost all of the characters and symbols in the
world!
<meta name="description" content="This is a description of my
web page.">
File Structure:
Explanation:
• index.html: with one h1 heading tag carrying your university name and a p tag
describing your university.
• about.html: with one h1 heading tag carrying your name and a p tag describing
yourself.
• contact.html: a form with 2 inputs: one for username and one for password
Food Prices
Food-name Food price