HTML Basics
HTML Basics
HTML (HyperText Markup Language) is the standard language for creating webpages. It
structures web content and uses various tags to define elements like headings, paragraphs, links,
images, and more.
html
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document Title</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a paragraph of text.</p>
</body>
</html>
Explanation:
HTML offers six levels of headings, from <h1> (most important) to <h6> (least important).
html
Copy code
<h1>Main Heading</h1>
<h2>Sub Heading</h2>
<h3>Sub-sub Heading</h3>
Paragraphs
html
Copy code
<p>This is a paragraph.</p>
Links
html
Copy code
<a href="https://www.example.com">This is a link</a>
Images
html
Copy code
<img src="image.jpg" alt="Description of the image">
Lists
html
Copy code
<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
html
Copy code
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
Tables
html
Copy code
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
3. HTML Attributes
HTML tags can have attributes that provide additional information about elements. They are
always included in the opening tag.
Example:
html
Copy code
<a href="https://www.example.com" target="_blank">Visit Example</a>
4. Semantic HTML
Semantic HTML introduces tags that clearly describe their purpose in the webpage.
Examples:
Using semantic HTML helps with search engine optimization (SEO) and accessibility.
5. Forms
HTML forms are used to collect user input. They contain elements like text fields, radio buttons,
checkboxes, etc.
html
Copy code
<form action="/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
Audio:
html
Copy code
<audio controls>
<source src="audiofile.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
Video:
html
Copy code
<video controls>
<source src="videofile.mp4" type="video/mp4">
Your browser does not support the video element.
</video>
7. Comments
You can add comments in HTML that are ignored by the browser. They are helpful for
organizing and explaining the code.
html
Copy code
<!-- This is a comment -->
8. HTML Entities
HTML entities are used to display reserved characters or symbols that otherwise have special
meaning in HTML.
Examples:
< = <
> = >
& = &
html
Copy code
<link rel="stylesheet" href="styles.css">
Linking JavaScript:
html
Copy code
<script src="script.js"></script>
These notes provide a solid foundation for understanding the basics of HTML. You can build
more complex and interactive web pages by combining these concepts with CSS and JavaScript!