HTML basic to advance
HTML, or Hypertext Markup Language, forms the foundation of web development. It's used to create the structure and content of web pages. Here are some basics:
1. HTML Structure: Every HTML document starts with a <!DOCTYPE html>
declaration, followed by an <html>
element that contains <head>
and <body>
sections.
```html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>
```
2. Head Section: Contains meta-information about the document, such as <title>
, <meta>
, <link>
, etc.
```html
<head>
<title>My Page</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
</head>
```
3. Body Section: Contains the main content of the document, structured using HTML elements.
```html
<body>
<h1>Main Heading</h1>
<p>This is a paragraph.</p>
<a href="https://www.example.com">Link to Example</a>
<img src="image.jpg" alt="Description of image">
</body>
```
4. Elements: HTML elements are defined by tags like <tagname>content</tagname>
. Common elements include:
- <h1>
to <h6>
: Headings
- <p>
: Paragraphs
- <a>
: Links
- <img>
: Images
- <ul>
, <ol>
, <li>
: Unordered and Ordered lists
- <table>
, <tr>
, <td>
: Tables and their rows/cells
- <form>
, <input>
, <button>
: Forms and form elements
5. Attributes: Elements can have attributes that modify their behavior or appearance.
```html
<a href="https://www.example.com" target="_blank">Link</a>
<img src="image.jpg" alt="Description">
```
6. Comments: Use <!-- comment -->
to add comments in HTML.
```html
<!-- This is a comment -->
```
7. Semantic HTML: Use tags that convey the meaning of the content, like <header>
, <nav>
, <main>
, <section>
, <article>
, <footer>
, etc.
```html
<header>
<h1>Website Header</h1>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<main>
<section>
<h2>Section Heading</h2>
<p>Section content...</p>
</section>
</main>
<footer>
<p>© 2024 My Website</p>
</footer>
```
8. Validation: Always ensure your HTML code is valid by using tools like the W3C Markup Validation Service (https://validator.w3.org/).
HTML is versatile and forms the backbone of web development, providing the structure and layout of web pages that are rendered by web browsers.this e book contain the html from basics to advance.