Sitemap

HTML From Beginner to Advanced Part 1: Getting Started

Learn the main and more useful HTML tags by learning how to use this markup language.

--

1. Hypertext Markup Language

2. Four Markup Languages: SGML, XML, HTML and XHTML

3. Tags

4. Attributes

5. Basic Structure of HTML

6. HTML Tags

7. Exercise

8. HTML Tags part 2

9. Images formats

10. Relative vs absolute Paths

11. HTML Tags part 3

12. Code Comments

Press enter or click to view image in full size
Photo by Jackson So on Unsplash

Hypertext Markup Language

A markup language is a system for annotating a document in a way that is syntactically distinguishable from the text. […] The whole idea of a mark up language is to avoid the formatting work for the text, as the tags in the mark up language serve the purpose to format the appropriate text like a header or beginning of a next paragraph…etc.

The red parts are indicating that within them text is going to be inserted. See the first pair of brackets.
See the first pair of brackets, that indicates that everything within is text.

Four Markup Languages: SGML, XML, HTML and XHTML

Press enter or click to view image in full size

SGML

Standard Generalized Markup Language (1986) From IBM’s 1969 GML: Generalized Markup Language. The markup is declarative. The markup is rigorous. Have to use Document Type Definitions (DTD).

XML

Extensible Markup Language (1996): simplicity, generality and usability across the Internet.

HTML

Hypertext Markup Language (1993). A markup language that web browsers use to interpret and compose text, images, and other material into visual or audible web pages.

The first publicly available description of HTML was a document called “HTML Tags”, first mentioned on Internet by Tim Berners-Lee in late 1991, and considered to be an application of SGML. In 2004, development began on HTML5 in the Web Hypertext Application Technology Working Group (WHATWG).

XHTML

Extensible Hypertext Markup Language (2000). An application of XML, a more restrictive subset of SGML.

XHTML 1.0 is “a reformulation of the three HTML 4 document types as applications of XML 1.0”. Developed to make HTML more extensible and increase interoperability with other data formats.

Press enter or click to view image in full size
Start here if you don’t know about code editors

Tags

Non visible on screen for the users of WebSites. The tags explain to your computer what it has to show on the screen.

Surrounded by < > like → <tag>

→ indicate the text nature which they are surrounding : this is the title, an image, a paragraph,… of our page

2 types of tags :

  • Pairs tags

Need and open tag and ending tag : <title> This is a title </title>

Indicate to the computer that everything which is not between these 2 tags is not a title

→ This is not a title <title>This is a title</title> This is not a title

  • Orphan tags

Used for insertion of elements at the precise place (for example a picture — <picture/>)

There is no need to open a tag and placing an end tag, we just want to say to the computer “add a picture here”

The / is optional but it’s recommended to had since it as a good practice between developers.

Attributes

Used in order to add options and provide more informations about the tag. Always placed after the name of the open tag. Most of the time has a value.

<tag attribute=”value”>

Example :

<quote writer=”Neil Armstrong” date=”21/07/1967”>

That’s one small step for man, one giant leap for mankind

</quote>

Basic Structure of HTML

Press enter or click to view image in full size

<!DOCTYPE html>

The DOCTYPE is retained in HTML5 as a mostly useless, but required header only to trigger “standards mode” in common browsers. Type declaration

<html> … </html>

<html> tag is the first tag that we have to open and the last one to close.

<html><body></body></html> this is good.

<html><body></html></body> : this is not.

<head> … </head>

There is no attributes for this tag. The start and end tag can always be omitted as they can be readily inferred by the parser. In the head element the information corresponds to the top part of a memo or mail message. It describes properties of the document such as the title, the document toolbar, and additional meta-information. All the informations in this section are hidden for the user.

<title> … </title>

The <title> element is always required. The title should identify the contents of the document in a global context, and may be used in a history lists and as a label for the window displaying the document. The TITLE element must occur within the head of the document, and may not contain anchors, paragraph tags, or highlighting. There is only one TITLE tag.

The length of the title is unlimited, however, long title may be truncated in some applications. To minimize this possibility, keep titles to fewer than 64 characters.

<meta … />

Meta information can be extracted by servers/clients for use in identifying, indexing and cataloging specialized document meta-information.

The META element attributes:

Charset

You need to specify the encode of your page with : <meta charset=”utf-8″ /> — indicate the way your file gonna be saved.

Example with it:

Example without it:

HTML Tags

<body> … </body>

This is where you will write all of your HTML code. The document body is composed from zero or more of the following elements:

  • DIV — used for hierarchical containers and static banners
  • Headings (H1, to H6) — a set of headers of varying levels of importance
  • Block elements — paragraphs, lists, forms, tables, figures and other elements
  • Horizontal rules, and the ADDRESS element
  • Text and character level markup including emphasis, images, math, hypertext links and miscellaneous elements.

<p> … </p>

Used to create paragraphs

The jump to the line that you do in visual code are not interpreted as it is by the browser. Everything will be written in one line. that’s why we use the <p> tag for example in order to separate our text.

<br/>

As you saw with <p> if you just want go to the next line without the creation of a new paragraph, then you have to use <br/>. <br /> has to be in a paragraph section.

Press enter or click to view image in full size

If you want to do multiple jump to the line then is better to use CSS.

Exercise

Create your first Website as follow :

Get Devon Developer’s stories in your inbox

Join Medium for free to get updates from this writer.

In order to do that :

  1. Create a folder named MyFirstWebSite

2. Then create 3 folders :

  • MyFirstWebSite/MyResume
  • MyFirstWebSite/MyAdventure
  • MyFirstWebSite/Images

3. In MyFirstWebSite/MyResume create your file aboutMe.html using visualStudio.

4. Complete your file aboutMe.html to look like the one below.

HTML Tags part 2

<h1> …. <h6>

Used to highlight part as a title/header in your document. Each of them has a particular style.

<strong>, <em> and <mark>

Used to indicate important words/sentences in your page.

Press enter or click to view image in full size

List

Used to order your website.

2 types of lists :

Non-ordered <ul>

  • Item1
  • Item2
  • Item3

Ordered <ol>

  1. Item1
  2. Item2
  3. Item3

Images formats

Jpeg (Joint Photographic Expert Group) .jpg or .jpeg

Used to lightening the weight of your image using algorithms based on the human sight. Very useful when you want to add pictures (users can’t see the difference).

Png (Portable Network Graphics)

No deterioration of your image but is heavier.

2 assets : you can use transparency and no deterioration of the quality of your image.

2 encodings :

  • PNG 8 bits : 256 colors ;
  • PNG 24 bits : 16 millions de colors (as much as JPEG).

Naming images :

lowercases, no accentuation and no spaces (use underscore instead).

Relative vs absolute Paths

Relative : No initial ‘/’ — browser looking for file in the current folder

folder/page.html → browser will looking for page.html directly in the folder named “folder”.

./folder/page.html → ./ browser look for the file in the current repertory folder

../folder/page.html → ../ browser look for the file in the parent folder

You can add ‘../’ as ../../../folder/page.html → parent3/parent2/parent/folder/page.html

Absolute : ‘/’ as a prefix of the path — browser looking for file at the root

/folder/page.html → browser will looking for http://www.myfirstwebsite.com/folder/page.html

Absolute is the safest convention name but if you modify your folder tree then you have to modify everything.

HTML Tags part 3

Orphan tag : <img />

With this tag you can add images . First tag where you will need attributes.

Attribute src explain where your computer will find the good image to insert in your website.

Attribute alt give an alternate sentence/keywords (used by browsers to index your image too).

Attribute title add informations like a tooltip on mouse over of your image.

In order to add a tag <img /> you have to add it between <p>…</p> tags.

Press enter or click to view image in full size
Press enter or click to view image in full size

<figure>….</figure>

What is exactly roles of <figure> vs <img/> ?

If the image gives no informations and it’s just a decoration of your Website then use <img/>.

If the image gives informations then use <figure> :

  • <figure> first role is semantical, indicate to computer that this image has meaning for your Website and it helps to understand your text.
  • With this tag you can use a program to generate a figure summary
  • A figure can have multiple images and usually one figcaption

<a/>

Can define a command, an action to do, this tag needs also attributes as follow:

Press enter or click to view image in full size
Press enter or click to view image in full size

A link which displays a tooltip on mouseover:

Using optional attribute title, you can use it to warn or inform the user before he clicks on your link.

Press enter or click to view image in full size

A link which open a new window

You can force the opening of a new window using attribute target = “_blank” with <a> tag.

Press enter or click to view image in full size

Depending on the browser configuration, the page will be displayed in a new window or tab. You can’t choose between window or tab. Don’t abuse of this technique as it disrupts navigation. The visitor himself can decide if he wants to open the link in a new window. It will Shift + Click on the link to open in a new window or Ctrl + Click to open in a new tab.

Link to send an email

Press enter or click to view image in full size

Link to download a file

Add this file directly in the same folder or another folder and do a link to this file.

Press enter or click to view image in full size

Landmark that you can put in your HTML pages when they are very long

Useful to make a link leading down the same page so that the visitor can jump directly to the part that interests him. To create an anchor, just add the id attribute to a tag that will serve as a reference. It can be any tag, a title for example.

This id will serve as an identifier in order to make a link to this title.

Press enter or click to view image in full size

If you click on the link, it will take you further down the same page (when provided enough text for the scrollbars to move automatically).

Every attribute id in your browser have to be named by an unique name

Link to an anchor in another web page:

The idea is to make a link that opens another page AND that leads directly to an anchor located lower on this page.

Press enter or click to view image in full size

Code Comments

In order to communicate about your code between developers every code languages own is method to do comments. You can place comments everywhere in order to explain what you are doing for example:

If you find my content helpful please consider making a donation at:

https://ko-fi.com/devondeveloper

This content it’s free but believe me, if you take a coding bootcamp or web development course there is no real difference with the information you just read. By making a donation You are helping to keep creating Great Quality content for You, so you can become the Best web developer you can be.

Back to the top.

--

--

Devon Developer
Devon Developer

Written by Devon Developer

Don’t waste your money with bootcamps. See my stories, ask questions and I will do my best to answer you. Please consider: https://ko-fi.com/devondeveloper