HTML Notes
Useful Links
- HTML DOG - HTML, CSS, and JavaScript tutorials
- W3 Schools - Style Guide
- W3 Schools - General HTML Reference
- MDN Web Docs - General HTML Reference
Dev Note: Originally, link text became bold on hover but I was advised not to do that as it moves elements of the page around, so I have reluctantly removed that.
HTML Basics
Tags
HTML uses tags to format and structure web content. These tags are made up of angled brackets around the content you want to structure.
<p>content</p>
The above example is of the paragraph tag. It starts with the opening tag <p>, then the content of the paragraph, and ends with the closing tag </p>. Most tags have opening and closing tags but some are self closing like the line break tag <br>.
Attributes
Attributes are included within tags to provide information about the HTML elements. For example, you can use the anchor tag with a href attribute to provide a clickable link.
<a href="https://www.htmldog.com/">Link Text</a>
The anchor tag defines a hyperlink and the href attribute specifies the URL or location of a link within the anchor tag.
Meaning and Presentation
It is worth stating early that htmldog stresses the importance of using HTML to specify meaning and using CSS to specify how your website is presented. For example, whilst you can emphasise text with the emphasis tags <em> and you can idicate importance with the strong tags <strong>, I get the impression you probably shouldn't. Instead, you can use CSS for that.
To further complicate things, the HTML tags which cause a visual change look to have a specific use case and to further complicate things, tags such as <strong> and <b> or <em> and <i> can result in the same visual change but have different use cases. That sort of thing is beyond the scope of this page, but you can read more here.
Some Useful Tags
THIS IS AS FAR AS I GOT WITH THE NEW FORMATTING, STOP READING LEST YOU JUDGE ME
Image Formats
There are a number of image formats we can use. Here as some of the most common:
- JPEG - JPEGs use an algorithm to compress the image at the expense of clarity
- GIF - limited to 256 colours and transparent pixels. Less colours = lower file size
- PNG - limited to 16m colours and alpha transparency.
Tables for Structured Date
Don't be tempted to use tables to change the layout of your webpage. Make sure you stick to CSS for that
Tables are created with the <Table> tag, Table Rows are created with the <tr> tag, and table cells are create with the <td> tag.
You can also use the <Caption> tag to insert a caption (which functions like a title) or the <th> tags to insert a header row
Column 1 | Column 2 | Column 3 |
---|---|---|
Row 1, Cell 1. | Row 1, Cell 2. | Row 1, Cell 3. |
Row 2, Cell 1. | Row 2, Cell 2. | Row 3, Cell 3. |
Row 3, Cell 1. | Row 3, Cell 2. | Row 3, Cell 3. |
Forms
Usually forms are used alongside a programming language that does something with the user inputs. The tags we'll look at are:
- <form> - this defines the form and we can use the <action> tag to tell the form where to send the contents
- <input>
- <textarea>
- <select>
- <option>
HTML Intermediate Tutorial
TutorialSpan & Div
Span and Div are used to group together chunks of HTML and hook information to it (usually class or id) so that you can link it to some CSS down the line.
- Span elements are in-line and go within other tags
- Div elements are block-line and cover multiple lines of HTML
Examples
This is a paragraph within a span tag around these three words with the id "blue_block" and I have used CSS to change the font colour to blue.
This is a paragraph within a div tag with the id "blue_block" and I have used CSS to change the font colour to blue.
Abbreviations
The abbreviation tag <abbr> is used for abbreviations and allows you to use the title attribute to define the abbreviation. See the example below:
HTML and CSS are both abbreviations but only the first utilises the title attribute.
Quotations
Much like <span> and <div> there are tags for quotations for both in-line and block-line elements.
- The q tags <q> are used for smaller, in-line quotations
- The blockquote tags <blockquote> are used for standalone, longer quotations
- dl - descriptive list tag, opens the list, similar to ul or ol
- dt - terms elements
- dd - description element
- Term 1
- Description of Term 1
- Term 2
- Description of Term 3
- Term 3 (with no description)
- Term 4 (with multiple descriptions)
- 1st description of Term 4
- 2nd description of Term 4
- 3rd description of Term 4
- 4th description of Term 4
- 0123-456-7890
- author_dude@noplaceinteresting.com
- http://www.noplaceinteresting.com/contactme/
- <bdo> - bidrectional override
- dir - required attribute to specify the direction of the change, can be ltr (left-to-right) or rtl (right-to-left)
- <ins> - show editorial insertions
- <del> - show editorial deletions
Messing Around with rowspan & colspan
Column 1 heading | Column 2 heading | Column 3 heading |
---|---|---|
Row 2, cell 1 | Row 2, cell 2, also spanning Row 2, cell 3 | |
Row 3, cell 1, also spanning Row 4, cell 1 | Row 3, cell 2 | Row 3, cell 3 |
Row 4, cell 2 | Row 4, cell 3 |
Descriptive Lists
Used for a list of terms and associated descriptions.
<!--DESCRIPTIVE list in HTML-->
<p>Descriptive List:</p>
<dl>
<dt>Term 1</li>
<dt>Description of Term 1</li>
<dt>Term 2</li>
<dt>Description of Term 2</li>
<dt>Term 3 with no description</li>
<dt>Term 4 of an ordered list</li>
<dd>1st description of Term 4</li>
<dd>2nd description of Term 4</li>
<dd>3rd description of Term 4</li>
</dl>
Descriptive List:
Address Tags
Author contact details
Definition Terms
You can define terms with the dfn tag and use the title attribute title to provide a description that is available on mouseover.
Frost seems to be getting absolutely turbogapped by Fire and Arcane this season.
Bi-directional Text
"Example Text" - no <bdo> tags
"Example Text" - with <bdo dir="ltr"> tags
Editorial Tags
I have decided to decrease increase the amount of free ice cream that the State will provide for its citizens.
Sectioning
Used to define specific parts of a page with more meaning than we would get by using <div>.
This would be the introduction of an article
This would be the main content of an article
This would be the conclusion of an article
Header and Footer
You can use multiple of these. A header or footer for each article or a header and footer for the page as a whole