Getting started with HTML

  1. Download and install Visual Studio Code (VS Code).
  2. Create a new folder on your desktop.
  3. Open the folder in VS Code.
  4. In VS Code, create a new file named index.html.
  5. In the index.html file, type html:5 and hit Enter (or just copy/paste in the following boilerplate code):
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document
    </head>
    <body>

    </body>
    </html>
  6. Type hello world! in the body of the file (between <body> and </body>).
  7. Save the file.
  8. From the folder on your desktop, double click the index.html file. It should open in a web browser.
  9. See your webpage!
  10. Return to VS Code. Update hello world to some other text. Save the file. Refresh the webpage and see your update.

Basics of HTML

HTML stands for HyperText Markup Language. HTML defines the content and structure of a webpage.

You can use the Inspect feature in Firefox or Google Chrome to see the HTML that defines this webpage.


HTML is structured using elements. HTML elements are defined by tags that look like this:

<tag> content goes here </tag>

There are many different tags that define different types of content. For example:

There are many more ☺



Here are some examples of simple HTML webpages:

Practice

Add content and structure to your index.html webpage.

For now, just add content. We will talk about style when we learn about CSS.

SEO

SEO stands for Search Engine Optimization, and refers to ways of increasing the likelihood that your webpage will appear in the results for relevant searh engine (Google, Ecosia, Bing, etc.) searches. Search engines parse the HTML of webpages for key words, looking in the title, header (h1 – h6) tags and the img alt text. You can also directly provide these key words by adding a description for your page (and naming yourself as the author, while you're at it).

Add the following meta tags in the <head></head> of you HTML document, filling in your own information as necessary. It is best practice to keep the description under 105 characters:

<head>
  ...
  <meta name="description" content="Tutorial for refining details of HTML webpages">
  <meta name="author" content="AnneMarie Torresen">   ...
</head>

Also, if you don't want your page to appear in search engine results, you can include the following in your HTML <head></head>:

<head>
  ...
  <meta name="robots" content="noindex">
  ...
</head>

Code Hygeine

comments

To add a code comment that will appear in your .html file but not on your webpage, surround text with <!-- and -->

<!-- this is a comment in HTML -->
<!-- use comments to keep track of what your code is doing -->

Each coding language has its own syntax for indicating a comment. In VS Code, you can comment out a line of code using the Cmd+/ or Ctrl+/ keyboard shortcut.

whitespace

Even though it won't affect how your webpage renders, it is best practice to use consistent whitespace (spaces, tabs, and line breaks) throughout your code files.

For example, keep the opening and closing tags of an element at the same indentation level and indent tags nested inside others (this can help you avoid tag soup):

<table>
    <tr>  <!-- 1 tab in -->
        <td> <!-- 2 tabs in --> </td>
        <td> <!-- 2 tabs in --> </td>
    </tr>
    <tr>  <!-- 1 tab in -->
        <td> <!-- 2 tabs in --> </td>
        <td> <!-- 2 tabs in -->/span> </td>
    </tr>
</table>

Cleanly formatted code with plenty of comments is easier to read -- you will thank yourself in the long run.