HTML_Tutorial
HTML_Tutorial
Every HTML document has a basic structure with essential tags. Here's a simple example:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
```
- `<!DOCTYPE html>`: This declaration tells the browser to expect HTML5 code.
- `<html lang="en">`: The root element of the HTML document. `lang="en"` specifies the language of
- `<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 supports
most characters).
- `<title>`: Defines the title of the webpage, which appears in the browser tab.
- `<body>`: Contains the main content of the webpage (text, images, links, etc.).
- `<h1>`: Represents the main heading of the page. `<h1>` is typically the largest and most
important heading.
Here are some other common elements you will often use in HTML:
- Headings:
- `<h1>`, `<h2>`, `<h3>`, etc., are used for headings of different levels, from `<h1>` (most
- Paragraphs:
- Links:
- `<a href="URL">Text</a>`: Creates a hyperlink. The `href` attribute specifies the link's
destination.
```html
<a href="https://www.example.com">Visit Example</a>
```
- Images:
- `<img src="image.jpg" alt="description">`: Embeds an image. The `src` attribute specifies the
image file, and the `alt` attribute provides a description if the image cannot be displayed.
```html
```
- Lists:
```html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
```
```html
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
```
- Divisions (for organizing content):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>Welcome to My Website</h1>
<h2>Unordered List</h2>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<h2>Ordered List</h2>
<ol>
<li>Introduction</li>
<li>Learning HTML</li>
<li>Building Webpages</li>
</ol>
<h2>Link Example</h2>
<h2>Image Example</h2>
<h2>Div Example</h2>
</div>
</body>
</html>
```
4. More Tips:
- Tags like `<meta>`, `<img>`, and others that don't have closing tags are self-closing.