50 HTML Codes
50 HTML Codes
Here are 50 HTML code snippets for various elements and features commonly used in web
development:
1. **HTML Boilerplate:**
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Website</title>
</head>
<body>
</body>
</html>
```
2. **Heading Tags:**
```html
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
```
3. **Paragraph:**
```html
```
```html
```
5. **Image Tag:**
```html
```
6. **Line Break:**
```html
```
7. **Unordered List:**
```html
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
```
8. **Ordered List:**
```html
<ol>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ol>
```
9. **Nested Lists:**
```html
<ul>
<li>Item 1
<ul>
<li>Subitem 1</li>
<li>Subitem 2</li>
</ul>
</li>
<li>Item 2</li>
</ul>
```
```html
<div>
</div>
```
```html
```
```html
```
```html
```
```
```html
<hr>
```
```html
```
```html
```
```html
<label for="name">Name:</label>
```
```html
<input type="text">
<input type="password">
<input type="email">
<input type="number">
<input type="date">
<input type="checkbox">
<input type="radio">
```
20. **Textarea:**
```html
```
```html
<select>
</select>
```
22. **Button:**
```html
<button>Click Me</button>
```
```html
<label>
</label>
<label>
</label>
```
24. **Checkbox:**
```html
<label>
</label>
```
<label for="email">Email:</label>
```
```html
```
```html
```
```html
```
```html
```
30. **HTML Tables:**
```html
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
```
```html
<table>
<tr>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 3</td>
</tr>
</table>
```
```html
<header>
<h1>Website Header</h1>
</header>
<nav>
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
<main>
<article>
<h2>Article Title</h2>
</article>
</main>
<footer>
</footer>
```
```html
<audio controls>
</audio>
```
```html
</video>
```
```html
```
```html
<meta name="description" content="Website description">
```
```html
```
```html
```
```html
</svg>
```
```html
<p id="demo"></p>
<script>
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
function showPosition(position) {
</script>
```
```html
<script>
function allowDrop(event) {
event.preventDefault();
function drag(event) {
event.dataTransfer.setData("text", event.target.id);
function drop(event) {
event.preventDefault();
event.target.appendChild(document.getElementById(data));
</script>
```
```html
```
```html
```
```html
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
function showPosition(position) {
var mapOptions = {
zoom: 10,
};
map: map,
});
</script>
```
45. **HTML Video Autoplay with Loop:**
```html
</video>
```
```html
</video>
```
```html
</video>
```
</video>
<script>
function changeSpeed() {
video.playbackRate = speedSlider.value;
</script>
```
```html
</video>
<button onclick="toggleFullscreen()">Fullscreen</button>
<script>
if (video.requestFullscreen) {
video.requestFullscreen();
} else if (video.mozRequestFullScreen) {
video.mozRequestFullScreen();
} else if (video.webkitRequestFullscreen) {
video.webkitRequestFullscreen();
} else if (video.msRequestFullscreen) {
video.msRequestFullscreen();
</script>
```
```html
</video>
<script>
video.currentTime = time;
</script>
```
These 50 HTML code snippets cover a range of elements and features that are commonly used in web
development. Use them as a reference to build your web pages and applications. Happy coding!