Back to top

HTML

Online Resources

HTML Cheat Sheet

Basics

Headings

Add separation line


This is an inserted line to show a new section. Use <hr> in brackets, no closing tag required.

To create a line break in text

To force a break
in a line of text,
use <br> in brackets,
no closing tag required.

To add 4 blank spaces in text

To type a < showing HTML code on website

Lists

HTML Elements

html elements table

Adding Images

To add an image you will use <img src="something.png" alt="Description of picture"> or something of the sort.

To add a link use an <a> tag

Internal Links

You can create a navbar with links that just link to another place on the same page.

You start by giving the new section an ID, and then place the ID in the html section of the link.

HTML Tables

Starts with <table> </table>. You can add nested rows <tr> </tr> and nested data within each row <td> </td>

You can also add a header row (thead) with a tr inside of it and then a th inside of that (automatically bold), table body (tbody), or footer row (tfoot). The reason you might want to use these different sections is in case you want to isolate one or more sections to style it differently or have one section behave differently.

One example of where you might do this is to make the table head sticky so that it doesn't move as you scroll through a table. This could be accomplished through CSS or javascript.

A simple table example using the table head assignment. th=table header, tr=table row, td=table data

 Header 1   Header 2 
 Box 1 data   Box 2 data 

Here is an example of a table used with one cell being my avatar and the other cell having all of my info. This makes it more interesting than just text below the image.

Avatar of Katie

Katie Lezon

Web Developer

I am a web developer, and a teacher. Check out my website at kate.reviews!

Form Basics

HTML Forms Cheat Sheet

All About Forms

Form Design Best Practices

Form Design Best Practices: 15 Tips to Boost Conversions and UX

Here are a few examples of different input options:

Audio settings:

Click for even more examples of different input types on MDN

Short Answer: Adding a Multi-Line Text Control

The <textarea>...</textarea> elements allow you to add a multi-line plain text control

Pull Down Menus

Select Control

The <select> control element allows you to have a pull down menu with a fixed list of options to choose from.

Example:

You can have your user choose multiple choices from the pull down menu by holding shift/control while clicking multiple answers, but it is better to use check boxes for that situation.

Titles & Groups within a Menu

If you have a long list and want to group the together use optgroup with label= to give it a heading in the menu.


The default value of a select control is always the first option.

To set a specific option to be selected when form loads add selected option

Checkboxes in HTML Forms

Checkbox Input Type

<input type="checkbox">

2 Ways to Get Values From Checkboxes

  1. Give each checkbox a different name and not specify a value.
    • → array(1) {['red']=>string(2)"on"}
  2. Give each checkbox the same name with an empty square brackets following it: name="colors[]", and then a different value attribute for each separate choice
    • → array(1) {['colors']=>array(2){[0]=>string(3)"red" [1]=>string(4)"blue"}}

Radio Buttons: Select Only One Option

<input type="radio">

This allows a user to only select a single value out of a number of set choices for submission in a form.

All radio buttons within the same question need two things:

  1. name="#" - Same name on each
  2. value="#" - Different value for each one, but best if it is same as label for radio button

Do you prefer cats or dogs?

Do you prefer cats or dogs?
<form>
 <label for="cats">Cats: </label>
  <input name="petChoice" id="cats" type="radio" value="cats">
 <label for="dogs">Dogs: </label>
  <input name="petChoice" id="dogs" type="radio" value="dogs">
 <button>Go!</button>
</form>

To select a radio button as default, add checked attribute

Labels in HTML Forms

<label></label> - Represents a caption for an item

By using this label for="title" you can now click on the word Title and the cursor will go into the box on the form. Also allows screen readers to describe the control.

Shortcut for Checkboxes & Radio Buttons

Instead of separating the input and label elements, you can wrap the input element inside of the label element. If you do it this way, you don't need an id attribute on the checkbox or a for attribute on the label. You can still click on the text to check the box using this alternative.


Instead of this:

Use this:

Placeholder Text

<input type="text" placeholder="username"> :
<input type="password" placeholder="password"> :

Fieldset

Example:

User:








Common Form Control Attributes

readonly

disabled

autofocus

Client-Side Form Validation

Form Validation:

Error message examples using client-side form validation:

Required Attribute

Example:

Pattern Attribute

Simple Password Requirements

Form Examples

Check source code or file for code for following example


Advanced Form Example:

Register


Contact Form Example - HTML only (no JS to validate)

<form action="mailto:hi@example.com" method="post" enctype="text/plain">
 <label>Your Name: </label>
 <input type="text" name="Name" value="">
 <label>Your Email: </label>
 <input type="email" name="Email" value="">
 <label>Your Message: </label>
 <textarea name="Message" rows="10" cols="50" placeholder="Your message here"></textarea>
 <button>Submit</button>
</form>





Adding Favicons to your Website

CSS-Tricks: Favicons Next to External Links

There are two different ways you can add a favicon to your website:

  1. Create your own favicon, save it in the same folder as your project, and link to it like so:
    • Add <link rel="icon" href="favicon.ico" type="image/x-icon"> in the head.
  2. You can use a Google shortcut to access a favicon already on a website and use it as yours.
    • Add <link rel="icon" type="image/png" href="https://www.google.com/s2/
      favicons?domain=jacinto.design">
      in the head.

Make Your Own Favicon

Favicon.cc

Favicon.io

Font Awesome

There are two different ways to add Font Awesome.

  1. Link to a CDN
  2. Use a kit link from their site

Image Maps

Image-Map.net

Create clickable images! With the help of our generator creating html imagemaps is free and easy. Simply start by selecting an image from your pc, or load one directly from an external website. Next up create your hot areas using either rectangle, circle or polygon shapes. Creating these shapes is as easy as pointing and clicking on your image. Don't forget to enter a link, title and target for each of them. Then once you're finished simply click Show Me The Code!