What is Hyper Text Markup Language?
HTML stands for Hypertext Markup Language.
- Hypertext is text which contains links to other text.
- Markup refers to tags and elements used within a document.
HTML is simply a text file with a specific structure that consists of elements and tags. Also take note that HTML files usually have a dot HTML suffix.
Each HTML element consists of an opening tag enclosed in angle brackets.
Elements can also be empty or self-closing, meaning they do not have a closing HTML tag. One example of a self-closing element is the line break tag. You can add a line break tag in a paragraph tag to move content to the following line by typing left angle bracket, the letters br, then right angle bracket. At the end of a self-closing tag, you simply add a right angle bracket. You can also close the right angle bracket by typing a forward slash right before it.
The rules and structure for elements and tags are known as the HTML specification. The HTML specification is maintained by the World Wide Web Consortium, or W3C, as it is commonly known.
Whenever the HTML specification changes, a new version of HTML is standardized, the current version is HTML 5.
HTML documents
<!DOCTYPE html
→ Shows browser that its and html document
<html> </html>
→ html root element
Then two main tags inside html tags:
<head> </head>
→ information and metadata about the html document & not a part of the content of the webpage<body> </body>
→ The content of the webpage
Simple HTML tags
There are many tags available in HTML. Here you will learn about common tags that you’ll use as a developer.
Headings
Headings allow you to display titles and subtitles on your webpage.
The following displays in the web browser:
Paragraphs
Paragraphs contain text content.
The following displays in the web browser:
NOTE
Note that putting content on a new line is ignored by the web browser.
Line Breaks
As you’ve learned, line breaks in the paragraph tag line are ignored by HTML. Instead, they must be specified using the <br>
tag. The <br>
tag does not need a closing tag.
The following displays in the web browser:
Strong
Strong tags can be used to indicate that a range of text has importance.
The following displays in the web browser:
Bold
Bold tags can be used to draw the reader’s attention to a range of text.
The following displays in the web browser:
Bold tags should be used to draw attention but not to indicate that something is more important. Consider the following example:
The following displays in the web browser:
Emphasis
Emphasis tags can be used to add emphasis to text.
The following displays in the web browser:
Italics
Italics tags can be used to offset a range of text.
The following displays in the web browser:
Emphasis vs. Italics
By default both tags will have the same visual effect in the web browser. The only difference is the meaning. Emphasis tags stress the text contained in them. Let’s explore the following example:
The following displays in the web browser:
Italics represent off-set text and should be used for technical terms, titles, a thought or a phrase from another language, for example:
The following displays in the web browser:
Screen readers will not announce any difference if an italics tag is used.
Lists
You can add lists to your web pages. There are two types of lists in HTML.
Lists can be unordered using the <ul>
 tag. List items are specified using the <li>
 tag, for example:
This displays in the web browser as:
Lists can also be ordered using the <ol>
 tag. Again, list items are specified using the <li>
 tag.
This displays as the following in the web browser.
Div tags
AÂ <div>
 tag defines a content division in a HTML document. It acts as a generic container and has no effect on the content unless it is styled by CSS.
The following example shows a <div>
 element that contains a paragraph element:
This displays as the following in the web browser.
It can be nested inside other elements, for example:
This displays in the web browser as:
As mentioned, the div has no impact on content unless it is styled by CSS. Let’s add a small CSS rule that styles all divs on the page.
Don’t worry about the meaning of the CSS just yet, you’ll explore CSS further in a later lesson. In summary, you’re applying a rule that adds a border and some visual spacing to the element.
This displays in the web browser as:
Div elements are an important part of building webpages. More advanced usage of div elements will be explored in another course.
Comments
If you want to leave a comment in the code for other developers, it can be added as:
The comment will not be displayed in the web browser.
Linking documents
Anchor tags
Create hyperlinks to link pages together
href → hypertext reference a → anchor
Adding images to a webpage with HTML
NOTE
Images are not inserted into web pages. Instead we use image tags in HTML to link to image files.
Set the dimensions of an image
Add alt description
ALT text
Not displayed on the site; read by assistive technologies and other accessibility tools
Use HTML to work with data in tables
tr → table row | td → table data
th → table header
What are forms?
To put it simply when a user enters data on a website an HTML form submits an HTTP request containing the data to the server.
Forms also have an optional form attribute called action. Actions specifies the URL or path that the form should submit the request to.
When the action attribute is not specified, it submits the request to the same path as the current web page.
There is also the FORM method, with the FORM method you can specify the HTTP method to use for the HTTP request. There are two HTTP methods to submit the form data, GET and POST.
First, let’s add a simple text field. For example, a user name field. The fields in a form are specified by input tags.
NOTE
Note that the input tag does not need a closing tag. But if I want to, I could close the tag by adding a forward slash before the end of the input tag.
You can add a label to make it more clear:
Creating a password field:
Adding a button:
When the user clicks the submit button, the HTTP request containing the form content will be sent to the web server.
There are many input types:
- Checkbox:
- Radio button: Checking one radio button will uncheck all the other radio buttons.
- Other input types:
WARNING
However, some input fields do not use the input tags.
- Multiple line as input:
- Drop-down list:
Introduction to the DOM
An HTML document must be represented in a certain way, so that JavaScript code can query and update it, to do this we use the document object model. When your web browser receives an HTML page, it constructs a DOM to represent it. DOM stands for Document Object Model and it is simply a tree, structure or model of the objects in your HTML file.
The DOM has a series of objects each representing a single HTML element. At the root of the DOM is the html object and it contains the head and body object. From there, the head object houses the title object and the title object contains its text object. The body object contains the two div objects, the first div houses, the h1 object which again houses its text object. The second div object contains the paragraph object which contains its text object.
In summary, all the elements in the HTML file are represented as objects in the document object model.(DOM helps JavaScript to update a part of the html file.)
Another major use of JavaScript and the DOM is to animate the HTML elements. This can be quite complex depending on the animation but there are many libraries available that aim to simplify this.
Web accessibility
When the Web accessibility Initiative or W. A. I. was launched in 1997, the creator of the World Wide Web. Sir, tim Berners lee said the power of
Sir, tim Berners lee
The Web is in its universality access by everyone regardless of disability is an essential aspect.
Web accessibility
allow people with disabilities to understand, navigate and interact with websites.
- Audio and visual
- Cognitive
- Physical
The W three C. Web accessibility initiative developed specifications and supporting resources for accessibility.
- Screen reader software
- Speech recognition software
- Subtitles and scripts
Having text that is not contained within proper tags like paragraph or heading tags makes it harder for assistive technologies to interact with the content. Similarly using multiple line breaks to break up text and add space also presents barriers to accessibility.
One of the tasks of the WAI, is to define the accessible rich internet application or ARIA specification. The aria specification outlines different techniques to improve accessibility for complex web apps.
Additional Resources
Learn more Here is a list of resources that may be helpful as you continue your learning journey.
HTML Elements Reference (Mozilla)
https://developer.mozilla.org/en-US/docs/Web/HTML/Element
The Form Element (Mozilla)
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
What is the Document Object Model? (W3C)
https://www.w3.org/TR/WD-DOM/introduction.html
ARIA in HTML (W3C via Github)
https://w3c.github.io/html-aria/
ARIA Authoring Practices (W3C)
https://www.w3.org/TR/wai-aria-practices-1.2/
Previous one → 2.Core Internet Technologies | Next one → 4.CSS Basics