# HTML, CSS and JavaScript Basics

# HTML Reference

# HTML Text and Headings

HTML provides elements for displaying text, headings and page structure.

Headings
Headings are used to organise content on a webpage.

HTML provides six heading levels.

<h1>Heading 1</h1>

<h2>Heading 2</h2>

<h3>Heading 3</h3>

<h4>Heading 4</h4>

<h5>Heading 5</h5>

<h6>Heading 6</h6>
Result:

Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Paragraphs
Paragraphs are used for normal text content.

<p>This is a paragraph.</p>

<p>This is another paragraph.</p>
Result:

This is a paragraph.

This is another paragraph.

Bold Text
Use the strong element to make text bold.

<strong>Important information</strong>
Result:

Important information

Italic Text
Use the em element to emphasise text.

<em>Important information</em>
Result:

Important information

Line Breaks
Use the br element to move text onto a new line.

Line One<br>
Line Two
Result:

Line One
Line Two

Horizontal Lines
Use the hr element to create a horizontal divider.

<hr>
Result:

Subscript
Subscript is commonly used in science and mathematics.

H<sub>2</sub>O
Result:

H2O

Superscript
Superscript is commonly used for powers and exponents.

x<sup>2</sup>
Result:

x2

Combining Elements
Multiple text elements can be combined.

<h1>Science Report</h1>

<p>
    Water is written as
    H<sub>2</sub>O.
</p>

<p>
    The formula for area is
    x<sup>2</sup>.
</p>
Result:


Complete Example
<!DOCTYPE html>

<html>

<head>
    <title>Text Example</title>
</head>

<body>

    <h1>Heading 1</h1>

    <h2>Heading 2</h2>

    <p>This is a paragraph.</p>

    <strong>Bold text</strong>

    <br><br>

    <em>Italic text</em>

    <hr>

    H<sub>2</sub>O

    <br>

    x<sup>2</sup>

</body>

</html>
Quick Reference
Headings
<h1>Heading 1</h1>
<h6>Heading 6</h6>
Paragraph
<p>Paragraph text</p>
Bold
<strong>Bold text</strong>
Italic
<em>Italic text</em>
Line Break
<br>
Horizontal Rule
<hr>
Subscript
<sub>
Superscript
<sup>
You now know how to create headings and display text content in HTML.

Next tutorial: HTML Links and Images

# HTML Links and Images

Links allow users to navigate between pages and websites.

Images can be used to display photos, logos and graphics on a webpage.

---

## Creating a Link

Use the `a` element to create a hyperlink.

```html
<a href="page.html">Go to Page</a>
```

Result:

<a href="#">Go to Page</a>

When clicked, the browser will open the specified page.

---

## Linking to Another Website

Use a full web address when linking to an external website.

```html
<a href="https://www.google.com">
    Visit Google
</a>
```

Result:

<a href="https://www.google.com">Visit Google</a>

---

## Opening a Link in a New Tab

Add the `target="_blank"` attribute.

```html
<a href="https://www.google.com"
   target="_blank"
   rel="noopener noreferrer">

    Visit Google

</a>
```

Result:

<a href="https://www.google.com" target="_blank">Visit Google</a>

The `rel` attribute improves security when opening new tabs.

---

## Linking to an Email Address

Use the `mailto:` protocol.

```html
<a href="mailto:teacher@school.com">
    Email Teacher
</a>
```

Result:

<a href="mailto:teacher@school.com">Email Teacher</a>

When clicked, the user's email program will open.

---

## Creating an Image

Use the `img` element.

```html
<img src="images/dog.jpg"
     alt="Photo of a dog">
```

The `src` attribute specifies the image location.

The `alt` attribute provides alternative text if the image cannot be displayed.



![Photo of a Dog](https://mr.napper.au/uploads/images/gallery/2026-06/dog.jpg)

---

## Setting Image Width

Use the `width` attribute.

```html
<img src="images/dog.jpg"
     width="100"
     alt="Photo of a dog">
```

The image will be displayed at 100 pixels wide.

<img src="https://mr.napper.au/uploads/images/gallery/2026-06/dog.jpg"
     alt="Photo of a Dog"
     width="100">

## Responsive Images

A responsive image automatically scales to fit different screen sizes.

```html
<img src="images/dog.jpg"
     style="max-width:100%;"
     alt="Photo of a dog">
```

This is useful for:

- Phones
- Tablets
- Laptops
- Desktop computers

---

## Using an Image as a Link

Images can also be used as buttons.

```html
<a href="dogs.html">

    <img src="images/dog.jpg"
         alt="Dog">

</a>
```

When the image is clicked, the browser will open the specified page.

<a href="dogs.html">
<img src="https://mr.napper.au/uploads/images/gallery/2026-06/dog.jpg" alt="Dog">
</a>

---

## Displaying a Logo

A common use of images is displaying a website logo.

```html
<img src="images/logo.png"
     width="200"
     alt="Company Logo">
```

---

## Creating an Image Gallery

Multiple images can be displayed together.

```html
<img src="images/dog1.jpg"
     width="200"
     alt="Dog 1">

<img src="images/dog2.jpg"
     width="200"
     alt="Dog 2">

<img src="images/dog3.jpg"
     width="200"
     alt="Dog 3">
```

---

## Complete Example

```html
<!DOCTYPE html>

<html>

<head>
    <title>Links and Images</title>
</head>

<body>

    <h1>Links and Images</h1>

    <a href="page.html">
        Internal Page
    </a>

    <br><br>

    <a href="https://www.google.com"
       target="_blank"
       rel="noopener noreferrer">

        Google

    </a>

    <br><br>

    <a href="mailto:teacher@school.com">
        Email Teacher
    </a>

    <br><br>

    <img src="images/dog.jpg"
         width="300"
         alt="Photo of a dog">

</body>

</html>
```

---

## Quick Reference

### Internal Link

```html
<a href="page.html">
```

### External Link

```html
<a href="https://website.com">
```

### New Tab

```html
target="_blank"
```

### Email Link

```html
<a href="mailto:someone@email.com">
```

### Image

```html
<img src="image.jpg"
     alt="Description">
```

### Image Width

```html
width="300"
```

### Responsive Image

```html
style="max-width:100%;"
```

### Image Link

```html
<a href="page.html">

    <img src="image.jpg">

</a>
```

You now know how to create hyperlinks and display images in HTML.

Next tutorial: **HTML Lists and Tables**

# HTML Lists and Tables

Lists and tables are used to organise and display information on a webpage.

Lists are useful for displaying related items, while tables are useful for displaying data in rows and columns.

---

## Unordered Lists

An unordered list displays items using bullet points.

```html
<ul>
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ul>
```

Result:

- HTML
- CSS
- JavaScript



---

## Ordered Lists

An ordered list displays items using numbers.

```html
<ol>
    <li>Plan the website</li>
    <li>Create the HTML</li>
    <li>Add CSS styling</li>
</ol>
```

Result:

1. Plan the website
2. Create the HTML
3. Add CSS styling



---

## Nested Lists

Lists can be placed inside other lists.

```html
<ul>

    <li>Web Development

        <ul>
            <li>HTML</li>
            <li>CSS</li>
            <li>JavaScript</li>
        </ul>

    </li>

</ul>
```

Result:

- Web Development
  - HTML
  - CSS
  - JavaScript



---

## Definition Lists

Definition lists are useful for displaying terms and descriptions.

```html
<dl>

    <dt>HTML</dt>
    <dd>Creates webpage content.</dd>

    <dt>CSS</dt>
    <dd>Controls appearance and styling.</dd>

</dl>
```

Result:

[![](https://mr.napper.au/uploads/images/gallery/2026-06/scaled-1680-/image-1781436252459.png)](https://mr.napper.au/uploads/images/gallery/2026-06/image-1781436252459.png)<dl><dt>HTML</dt><dd>Creates webpage content.</dd><dt>CSS</dt><dd>Controls appearance and styling.</dd></dl>

---

## Creating a Table

Tables display information in rows and columns.

```html
<table>

    <tr>
        <th>Name</th>
        <th>Score</th>
    </tr>

    <tr>
        <td>Sam</td>
        <td>90</td>
    </tr>

</table>
```

Result:

| Name | Score |
|--------|--------|
| Sam | 90 |

---

## Understanding Table Elements

Tables are made up of:

| Element | Purpose |
|----------|----------|
| `<table>` | Creates the table |
| `<tr>` | Creates a row |
| `<th>` | Creates a heading cell |
| `<td>` | Creates a data cell |

---

## Adding Multiple Rows

```html
<table>

    <tr>
        <th>Name</th>
        <th>Score</th>
    </tr>

    <tr>
        <td>Sam</td>
        <td>90</td>
    </tr>

    <tr>
        <td>Alex</td>
        <td>85</td>
    </tr>

    <tr>
        <td>Jess</td>
        <td>95</td>
    </tr>

</table>
```

Result:

| Name | Score |
|--------|--------|
| Sam | 90 |
| Alex | 85 |
| Jess | 95 |

> **Screenshot Placeholder**
>
> Insert screenshot showing a table with multiple rows.

---

## Adding Borders

Tables often use CSS for styling.

```html
<table border="1">

    <tr>
        <th>Name</th>
        <th>Score</th>
    </tr>

    <tr>
        <td>Sam</td>
        <td>90</td>
    </tr>

</table>
```

Result:

A table with visible borders.

[![](https://mr.napper.au/uploads/images/gallery/2026-06/scaled-1680-/image-1781436313967.png)](https://mr.napper.au/uploads/images/gallery/2026-06/image-1781436313967.png)

---

## Merging Columns

Use `colspan` to combine columns.

```html
<table border="1">

    <tr>
        <th colspan="2">
            Student Results
        </th>
    </tr>

    <tr>
        <td>Sam</td>
        <td>90</td>
    </tr>

</table>
```

Result:

[![](https://mr.napper.au/uploads/images/gallery/2026-06/scaled-1680-/image-1781436364355.png)](https://mr.napper.au/uploads/images/gallery/2026-06/image-1781436364355.png)

---

## Merging Rows

Use `rowspan` to combine rows.

```html
<table border="1">

    <tr>
        <td rowspan="2">
            Year 10
        </td>

        <td>Sam</td>
    </tr>

    <tr>
        <td>Alex</td>
    </tr>

</table>
```

[![](https://mr.napper.au/uploads/images/gallery/2026-06/scaled-1680-/image-1781436405953.png)](https://mr.napper.au/uploads/images/gallery/2026-06/image-1781436405953.png)

---

## Complete Example

```html
<!DOCTYPE html>

<html>

<head>
    <title>Lists and Tables</title>
</head>

<body>

    <h1>Lists and Tables</h1>

    <h2>Favourite Subjects</h2>

    <ul>
        <li>Digital Technologies</li>
        <li>Engineering</li>
        <li>Science</li>
    </ul>

    <h2>Student Results</h2>

    <table border="1">

        <tr>
            <th>Name</th>
            <th>Score</th>
        </tr>

        <tr>
            <td>Sam</td>
            <td>90</td>
        </tr>

        <tr>
            <td>Alex</td>
            <td>85</td>
        </tr>

    </table>

</body>

</html>
```

---

## Quick Reference

### Unordered List

```html
<ul>
    <li>Item</li>
</ul>
```

### Ordered List

```html
<ol>
    <li>Item</li>
</ol>
```

### Definition List

```html
<dl>
    <dt>Term</dt>
    <dd>Description</dd>
</dl>
```

### Table

```html
<table>
```

### Table Row

```html
<tr>
```

### Table Header

```html
<th>
```

### Table Data

```html
<td>
```

### Merge Columns

```html
colspan="2"
```

### Merge Rows

```html
rowspan="2"
```

You now know how to create lists and tables in HTML.

Next tutorial: **HTML Forms**

# HTML Forms

Forms allow users to enter and submit information on a webpage.

Forms are commonly used for:

- Login systems
- Registration pages
- Contact forms
- Surveys
- Search boxes

---

## Creating a Form

A form is created using the `form` element.

```html
<form>

</form>
```

All form controls are placed inside the form element.

---

## Text Input

Use the `input` element to create a text box.

```html
<form>

    <input type="text">

</form>
```

Result:

<input type="text">


---

## Adding a Label

Labels describe the purpose of an input.

```html
<form>

    <label>
        Username:
    </label>

    <input type="text">

</form>
```

Result:

<label>Username:</label>

<input type="text">

---

## Placeholder Text

Placeholders provide hints to the user.

```html
<input
    type="text"
    placeholder="Enter username">
```

Result:

<input type="text" placeholder="Enter username">

---

## Password Input

Password fields hide the text being entered.

```html
<input
    type="password"
    placeholder="Enter password">
```

Result:

<input type="password" placeholder="Enter password">



---

## Email Input

Email inputs help validate email addresses.

```html
<input
    type="email"
    placeholder="Enter email">
```

Result:

<input type="email" placeholder="Enter email">

---

## Number Input

Number inputs only accept numeric values.

```html
<input
    type="number">
```

Result:

<input type="number">

---

## Text Areas

Text areas allow users to enter multiple lines of text.

```html
<textarea>

</textarea>
```

Result:

<textarea rows="4" cols="30"></textarea>

---

## Checkboxes

Checkboxes allow multiple selections.

```html
<input
    type="checkbox">

HTML
```

Result:

<input type="checkbox"> HTML

---

## Radio Buttons

Radio buttons allow a single selection from a group.

```html
<input
    type="radio"
    name="year">

Year 10

<br>

<input
    type="radio"
    name="year">

Year 11
```

Result:

<input type="radio" name="year"> Year 10

<br>

<input type="radio" name="year"> Year 11

---

## Dropdown Lists

Use the `select` element to create a dropdown menu.

```html
<select>

    <option>
        HTML
    </option>

    <option>
        CSS
    </option>

    <option>
        JavaScript
    </option>

</select>
```

Result:

<select>
<option>HTML</option>
<option>CSS</option>
<option>JavaScript</option>
</select>

---

## Submit Button

Buttons are used to submit forms.

```html
<button>

    Submit

</button>
```

Result:

[![](https://mr.napper.au/uploads/images/gallery/2026-06/scaled-1680-/image-1781436573670.png)](https://mr.napper.au/uploads/images/gallery/2026-06/image-1781436573670.png)

---

## Complete Login Form

```html
<form>

    <label>
        Username
    </label>

    <br>

    <input
        type="text"
        placeholder="Username">

    <br><br>

    <label>
        Password
    </label>

    <br>

    <input
        type="password"
        placeholder="Password">

    <br><br>

    <button>

        Login

    </button>

</form>
```

> **Screenshot Placeholder**
>
> Insert screenshot showing the login form.

---

## Form Submission

Forms can send data to another page.

```html
<form
    action="process.php"
    method="post">

</form>
```

### action

Specifies where the data will be sent.

```html
action="process.php"
```

### method

Specifies how the data will be sent.

```html
method="post"
```

or

```html
method="get"
```

Most login and registration systems use:

```html
method="post"
```

---

## Complete Example

```html
<!DOCTYPE html>

<html>

<head>
    <title>Forms Example</title>
</head>

<body>

    <h1>Student Registration</h1>

    <form
        action="process.php"
        method="post">

        <label>
            Name
        </label>

        <br>

        <input
            type="text"
            name="name">

        <br><br>

        <label>
            Email
        </label>

        <br>

        <input
            type="email"
            name="email">

        <br><br>

        <label>
            Year Level
        </label>

        <br>

        <select name="year">

            <option>
                Year 10
            </option>

            <option>
                Year 11
            </option>

            <option>
                Year 12
            </option>

        </select>

        <br><br>

        <button>

            Submit

        </button>

    </form>

</body>

</html>
```

---

## Quick Reference

### Form

```html
<form>
```

### Text Input

```html
<input type="text">
```

### Password Input

```html
<input type="password">
```

### Email Input

```html
<input type="email">
```

### Number Input

```html
<input type="number">
```

### Text Area

```html
<textarea>
```

### Checkbox

```html
<input type="checkbox">
```

### Radio Button

```html
<input type="radio">
```

### Dropdown

```html
<select>
```

### Button

```html
<button>
```

### Form Action

```html
action="process.php"
```

### Form Method

```html
method="post"
```

You now know how to collect user input using HTML forms.

Next tutorial: **HTML Embeds and Comments**

# HTML Embeds and Comments

HTML can be used to embed videos, maps and other content into a webpage.

Comments can also be added to help explain code without displaying anything on the page.

---

## HTML Comments

Comments are ignored by the browser.

They are useful for explaining code and leaving notes for yourself or other developers.

```html
<!-- This is a comment -->
```

Example:

```html
<!-- Navigation Menu -->

<nav>

</nav>
```

Comments are not visible on the webpage.



---

## Embedding a YouTube Video

YouTube provides embed code for videos.

Example:

```html
<iframe
    width="560"
    height="315"
    src="https://www.youtube.com/embed/W-Q7RMpINVo"
    allowfullscreen>

</iframe>
```

Result:

A YouTube video displayed on the page.

<iframe
    width="560"
    height="315"
    src="https://www.youtube.com/embed/dQw4w9WgXcQ"
    allowfullscreen>

</iframe>

---

## Responsive YouTube Videos

To help videos work on phones and tablets:

```html
<iframe
    width="100%"
    height="315"
    src="https://www.youtube.com/embed/W-Q7RMpINVo"
    allowfullscreen>

</iframe>
```

The video will automatically adjust to the available width.

---

## Embedding a Google Map

Google Maps can also be embedded.

Example:

```html
<iframe
    src="https://www.google.com/maps/embed..."
    width="600"
    height="450">

</iframe>
```

Result:

An interactive map displayed on the page.

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3520.366280272018!2d153.37404667577476!3d-28.07436817597404!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6b911cb972c15b2f%3A0xc34ef94511e30812!2sRobina%20State%20High%20School!5e0!3m2!1sen!2sau!4v1781436815960!5m2!1sen!2sau" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>

---

## Displaying a Video File

Videos stored in your project can be displayed using the `video` element.

```html
<video
    width="600"
    controls>

    <source
        src="videos/demo.mp4"
        type="video/mp4">

</video>
```

Result:

A video player with play and pause controls.

<video width="600" controls>
<source src="videos/demo.mp4" type="video/mp4">
</video>

---

## Displaying Audio Files

Audio can be embedded using the `audio` element.

```html
<audio controls>

    <source
        src="audio/music.mp3"
        type="audio/mpeg">

</audio>
```

Result:

An audio player with playback controls.

<audio controls><source src="audio/music.mp3" type="audio/mpeg"></audio>

---

## Displaying PDF Files

PDF documents can be embedded directly into a webpage.

```html
<iframe
    src="files/document.pdf"
    width="100%"
    height="600">

</iframe>
```

Result:

The PDF document is displayed inside the webpage.



---

## Common Uses for Embeds

Embeds are commonly used for:

- YouTube videos
- Google Maps
- PDF documents
- Audio players
- Demonstration videos
- Interactive content

---

## Complete Example

```html
<!DOCTYPE html>

<html>

<head>
    <title>Embeds Example</title>
</head>

<body>

    <h1>Media Examples</h1>

    <!-- YouTube Video -->

    <iframe
        width="560"
        height="315"
        src="https://www.youtube.com/embed/W-Q7RMpINVo"
        allowfullscreen>

    </iframe>

    <br><br>

    <!-- Audio Player -->

    <audio controls>

        <source
            src="audio/music.mp3"
            type="audio/mpeg">

    </audio>

</body>

</html>
```

---

## Quick Reference

### Comment

```html
<!-- Comment -->
```

### YouTube Video

```html
<iframe>
```

### Google Map

```html
<iframe>
```

### Video File

```html
<video>
```

### Audio File

```html
<audio>
```

### PDF

```html
<iframe src="document.pdf">
```

You now know how to embed media and add comments in HTML.

Next chapter: **CSS Reference**

# CSS Reference

# JavaScript Reference