HTML
HTML
HTML (HyperText
Markup Language) is a
fundamental technology
used to create web pages.
It consists of a series of
elements, which you can
use to structure the content
on the web page. Here's a
detailed breakdown:
An HTML document
typically consists of two
main parts: the head and
the body.
#### 1. `<!DOCTYPE
html>`
```html
<!DOCTYPE html>
```
```html
<html>
<!-- head and body
elements go here -->
</html>
```
#### 3. `<head>` Element
Contains meta-information
(metadata) about the
document, such as its title,
character set, and links to
stylesheets.
```html
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<meta name="description"
content="Free Web
tutorials">
<meta name="keywords"
content="HTML, CSS,
JavaScript">
<meta name="author"
content="John Doe">
<link rel="stylesheet"
href="styles.css">
</head>
```
```html
<body>
<!-- Content goes here -->
</body>
```
- **Headings**: Define
headings in the document.
There are six levels (`<h1>`
to `<h6>`).
```html
<h1>This is a heading</h1>
<h2>This is a sub-
heading</h2>
```
- **Paragraphs**: Define
paragraphs of text.
```html
<p>This is a
paragraph.</p>
```
- **Links**: Create
hyperlinks to other pages or
resources.
```html
<a
href="https://www.example.
com">This is a link</a>
```
```html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
```
- **Images**: Embed
images.
```html
<img src="image.jpg"
alt="Description of image">
```
- **Videos**: Embed videos.
```html
<video width="320"
height="240" controls>
<source src="movie.mp4"
type="video/mp4">
Your browser does not
support the video tag.
</video>
```
#### Forms
```html
<form action="/submit-form"
method="post">
<label
for="name">Name:</label>
<input type="text"
id="name" name="name">
<input type="submit"
value="Submit">
</form>
```
### Attributes
```html
<p id="unique-id">This is a
paragraph with an id.</p>
```
```html
<p class="my-class">This is
a paragraph with a
class.</p>
```
```html
<img src="image.jpg"
alt="Description of image">
```
```html
<a
href="https://www.example.
com">This is a link</a>
```
### Semantic HTML
Semantic HTML introduces
meaning to the web page
rather than just
presentation. Examples
include:
- **`<header>`**: Defines a
header for a document or
section.
- **`<nav>`**: Defines a set
of navigation links.
- **`<article>`**: Defines
independent, self-contained
content.
- **`<section>`**: Defines a
section in a document.
- **`<footer>`**: Defines a
footer for a document or
section.
```html
<!DOCTYPE html>
<html>
<head>
<title>My First HTML
Page</title>
<meta charset="UTF-8">
<meta
name="description"
content="An example HTML
page">
<meta name="keywords"
content="HTML, example">
<meta name="author"
content="Your Name">
<link rel="stylesheet"
href="styles.css">
</head>
<body>
<header>
<h1>Welcome to My
Web Page</h1>
</header>
<nav>
<ul>
<li><a
href="#section1">Section
1</a></li>
<li><a
href="#section2">Section
2</a></li>
</ul>
</nav>
<section id="section1">
<h2>Section 1</h2>
<p>This is the first
section of my web
page.</p>
<img src="image1.jpg"
alt="A descriptive image">
</section>
<section id="section2">
<h2>Section 2</h2>
<p>This is the second
section of my web
page.</p>
<video width="320"
height="240" controls>
<source
src="video.mp4"
type="video/mp4">
Your browser does
not support the video tag.
</video>
</section>
<footer>
<p>Contact
information: <a
href="mailto:someone@exa
mple.co
m">[email protected]
m</a>.</p>
</footer>
</body>
</html>
```