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:
- all content of an HTML page goes within the
<body> tag
- levels of headings are defined with
<h1>, <h2>, …, <h6> tags
<p> defines a paragraph of text
<ul> defines a bulleted list, <li> defines each list item inside
<a> defines a hyperlink to another webpage
There are many more ☺
Here are some examples of simple HTML webpages:
Practice
Add content and structure to your index.html webpage.
-
Search online to discover tags you can use. W3Schools has HTML Basic Examples that might be a good starting point.
-
And you can always ask a classmate -- there is lots of brainpower in this classroom!
-
You can also ask AnneMarie -- there is less brainpower in her, but it is sometimes still worth a try. Plus it's her job.
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 -->
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>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
Cleanly formatted code with plenty of comments is easier to read -- you will thank yourself in the long run.
<!-- use comments to keep track of what your code is doing -->