HTML Examples Guide
Basic HTML Structure
This is a basic HTML page structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Basic HTML Page</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a basic HTML page.</p>
</body>
</html>
Example:
Hello, World!
This is a basic HTML page.
HTML Forms
Forms are used to collect user input. Here's an example of a simple form:
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<input type="submit" value="Submit">
</form>
Example:
HTML Links
Links are used to navigate between pages. Here's an example of a hyperlink:
<a href="https://www.example.com">Visit Example</a>
Example:
HTML Lists
HTML supports ordered and unordered lists:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ol>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ol>
Examples:
- Item 1
- Item 2
- Item 3
- First
- Second
- Third
HTML Tables
Tables are used to display tabular data. Here's an example of a simple table:
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Example:
Header 1 | Header 2 |
---|---|
Data 1 | Data 2 |
HTML Media
HTML supports embedding media such as videos and audio:
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
<source src="audio.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
Examples:
HTML Forms with Validation
Forms can include various types of input fields and validation attributes:
<form action="/submit" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" minlength="4" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="Submit">
</form>
Example:
0 Comments