HTML
HTML
---
HTML is used to define the structure of web pages. It consists of a series of elements that
represent the content of a page, such as headings, paragraphs, images, and links.
---
```html
<head>
<title>My Webpage</title> <!-- Title of the page (shown in the browser tab) -->
</head>
<body>
<h1>Welcome to My Webpage</h1> <!-- Main heading -->
<p>This is a simple webpage created with HTML.</p> <!-- Paragraph of text -->
</body>
</html>
```
- `<!DOCTYPE html>`: Declares the document type and version of HTML being used
(HTML5 in this case).
- `<html lang="en">`: The root element that wraps the entire HTML document, with the
`lang` attribute specifying the language.
- `<head>`: Contains meta-information about the document (such as its title, character
set, and viewport settings).
- `<meta charset="UTF-8">`: Specifies the character encoding for the document (UTF-8 is
the most common).
- `<title>`: Defines the title of the webpage, which appears in the browser tab.
- `<body>`: Contains the visible content of the webpage (e.g., headings, paragraphs,
images).
---
HTML elements are enclosed in **tags**. Tags come in pairs: an opening tag and a closing
tag.
```html
<p>This is a paragraph</p>
```
Some elements are **self-closing** (don't have a closing tag), such as images and links:
```html
```
---
#### **Headings**
HTML has six levels of headings, from `<h1>` to `<h6>`. `<h1>` is the most important
and `<h6>` is the least.
```html
<h2>Subheading</h2>
<h3>Smaller Subheading</h3>
```
```html
```
#### **Links**
```html
```
- **Targeting Links**: You can use the `target="_blank"` attribute to open links in a new
tab.
```html
<a href="https://www.example.com" target="_blank">Visit Example in a new tab</a>
```
#### **Images**
```html
```
#### **Lists**
```html
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
```
#### **Forms**
Forms are used to collect user input. Some common form elements include:
```html
<label for="name">Name:</label>
<label for="email">Email:</label>
<button type="submit">Submit</button>
</form>
```
---
Attributes provide additional information about HTML elements. They are added inside the
opening tag.
Examples:
```html
</div>
```
---
```html
<table>
<th>Header 2</th>
</tr>
</tr>
</tr>
</table>
```
---
### **7. Semantic HTML**
Semantic HTML refers to using HTML tags that have meaningful names to describe the
content of a webpage, making it more accessible and SEO-friendly.
Examples:
```html
<header>
<h1>My Website</h1>
<nav>
<a href="#home">Home</a>
<a href="#about">About</a>
</nav>
</header>
<section>
<h2>About Me</h2>
</section>
<footer>
</footer>
```
---
HTML is the foundational language for web development. It allows you to structure content
on a webpage, from simple text to complex multimedia elements. The tags and attributes
you use in HTML determine how your content is displayed in the browser.
To create more complex websites, HTML is typically combined with **CSS** (for styling)
and **JavaScript** (for interactivity).
If you'd like to learn more about any specific part of HTML or need additional examples,
feel free to ask!