Code Beacon

Copy-ready HTML • CSS • JavaScript snippets
HTML Snippets
Basic HTML Document Structure
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My First Page</title>
</head>
<body>
  <h1>Hello World</h1>
  <p>This is my first webpage.</p>
</body>
</html>
Preview

Hello World

This is my first webpage.

Using Google Fonts
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Google Fonts Example</title>

  <!-- Link to Google Fonts -->
  <link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600&display=swap" rel="stylesheet">

  <style>
    body {
      font-family: 'Quicksand', sans-serif;
    }
  </style>
</head>
<body>
  <h1>Hello World</h1>
  <p>This text uses the Quicksand font from Google Fonts.</p>
</body>
</html>
Preview

Hello World

This text uses the Quicksand font from Google Fonts.

Headings
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Preview

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6
Paragraphs & Line Breaks
<p>This is a paragraph of text.</p>
<p>Here is another paragraph with a<br>line break.</p>
Preview

This is a paragraph of text.

Here is another paragraph with a
line break.

Horizontal Line
<p>First section of text.</p>
<hr>
<p>Second section of text after a horizontal line.</p>
Preview

First section of text.


Second section of text after a horizontal line.

Text Formatting
<p>This is a paragraph.</p>
<strong>Bold text</strong>
<em>Italic text</em>
<u>Underlined text</u>
<mark>Highlighted text</mark>
<del>Deleted text</del>
<ins>Inserted text</ins>
<sup>Superscript</sup> and <sub>Subscript</sub>
Preview

This is a paragraph.

Bold text
Italic text
Underlined text
Highlighted text
Deleted text
Inserted text
Superscript and Subscript
Text Color
<p style="color:red;">This is red text.</p>
<p style="color:blue;">This is blue text.</p>
<p style="color:green;">This is green text.</p>
<p style="color:#f7c84b;">This is custom hex color text.</p>
Preview

This is red text.

This is blue text.

This is green text.

This is custom hex color text.

Iframes
<iframe src="https://example.com" width="400" height="300" title="Example iframe"></iframe>
Preview
Audio
<audio controls>
  <source src="https://www.w3schools.com/html/horse.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>
Preview
Images
<img src="https://via.placeholder.com/150" alt="Placeholder image">
Preview
Placeholder image
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>
Preview
  • Item 1
  • Item 2
  • Item 3
  1. First
  2. Second
  3. Third
Table
<table border="1">
  <tr>
    <th>Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Alice</td>
    <td>25</td>
  </tr>
  <tr>
    <td>Bob</td>
    <td>30</td>
  </tr>
</table>
Preview
NameAge
Alice25
Bob30
Form
<form action="#" method="post">
  <label for="name">Name:</label>
  <input type="text" id="name" name="name">
  <br><br>
  <input type="submit" value="Submit">
</form>
Preview