1. HTML Overview

1.1 What is HTML?

HTML stands for HyperText Markup Language. It is the standard language used to create webpages. HTML is not a programming language, but rather a markup language that defines the structure of your content. HTML consists of a series of elements, which you use to enclose, or wrap, different parts of the content to make it appear or act a certain way. The enclosing tags can make a word or image hyperlink to somewhere else, can italicize words, can make words bold, and so on. HTML elements are represented by tags.

HTML Basics

HTML documents are made up of elements. These elements are represented by tags. Tags are keywords surrounded by angle brackets. Most tags have an opening tag and a closing tag. The closing tag is written the same as the opening tag, except that it includes a forward slash ( / ) before the tag name. For example, <p> is an opening paragraph tag, and </p> is a closing paragraph tag. The text or other HTML elements that are to be affected by the tag are placed between the opening and closing tags.

HTML Document Structure

An HTML document has a nested structure. The outermost element is the <html> element, which contains two main sections: the <head> and the <body>. The <head> section contains meta-information about the document, such as its title and links to stylesheets. The <body> section contains the content of the document, such as text, images, and links.

HTML Attributes

HTML elements can have attributes that provide additional information about the element. Attributes are placed within the opening tag of an element. An attribute consists of a name and a value, separated by an equals sign. For example, in the tag <a href="https://www.example.com">, "href" is the attribute name, and "https://www.example.com" is the attribute value. Attributes can be used to specify properties such as links, styles, and identifiers for elements.

HTML Best Practices

When writing HTML, properly use whitespace in the code to ensure it is easy to read. Indent text as well to ensure relationships between elements are clear.

Add comments to provide clarity to your HTML documents. Comments begin with <!-- and end with -->, and result in the contents performing no action.

HTML Elements

Text Values - Tags

Styling Text Elements

Media Elements

HTML tables

A table can be created on an html page by placing its structure inside of a pair of <table> tags. Each row is contained within a pair of <tr> tags. Each data value should be contained with <td> tags. Header values should be enclosed with <th> tags. An example of what this looks like is provided below.


An example of a table. (this text uses a caption tag just inside the table tag)
Okoorian family First Name Last Name
Person 1 Matthew Okoorian

Tables - Organization

The header row can be semantically labeled within a pair of tags using <thead>

Below the header row, table data can be organized with a tag called <tbody>

Finally, the footer row (where there could be totals or other information) can be enclosed in a tags set to <tfoot>.

Attributes

HTML Organizational Structure

Standard Organizing Tags

Semantic HTML

Semantic HTML makes reading HTML easier by ensuring the intention behind material is clearer. Here are some examples of semantic elements in the order they often appear.

  1. <header> - often used for a top bar on the page.
  2. <nav> - often used to frame a section where links to other content may be placed.
  3. <main> - used to contain the primary body of a webpage.
  4. <section> - used to contain a portion of the main, seperates portions of the page into discrete areas or topics.
  5. <article> - used to tag an item that stands on its own. Examples include articles, blogs, comments, magazines, etc.
  6. <aside> - used to tag information that enhances main information, but isnt critical. Examples include Bibliographies, Endnotes, Comments, Quotes, Additional Information.
  7. <figure> - used for media like pictures or video.
  8. <figcaption> - used to place text below a figure. Encompasses a text element. Usually enclosed within a figure tag alongside an img.
  9. <footer> - used to contain a block at the bottom of the page with additional navigation or contact details.

Element Attributes

HTML elements can be given additional attributes to effect how they are used. Attributes are set by placing within the opening tag a Property='Value'.
Example: <h1 id='test123'>

Common Attributes

  1. id - used to give specific element a unique identifier for reference elsewhere. Value should be unique.
  2. class - used to give an element a shared identifier so it may share configuration between itself and elements of a same class.

HTML tags with cool features

HTML Forms

Forms are used to collect user input. Forms are created using the <form> tag. Within the form tag, various input elements can be placed to collect different types of data. Common input elements include text fields (<input type="text">), radio buttons (<input type="radio">), checkboxes (<input type="checkbox">), and submit buttons (<input type="submit">). Each input element should have a "name" attribute to identify the data when the form is submitted.


Within a form element, assign the "action" attribute to specify where the form data should be sent when submitted, and the "method" attribute to specify how the data should be sent (e.g., GET or POST). A "value" and "placeholder" attribute can also be added to provide default values and hints for the user. When the form is submitted, the data is submitted in a manner to the provided URL connecting the "name=value".
Example: If the input name is "username" and "Mokoo001" is provided to the text field, the submit button will provide "username=Mokoo001" to the server.


Examples of a form and input elements:


Beef Chicken
Pepperoni Mushrooms Onions