HTML Tutorial for Beginner [2022] *Foundation HTML Basic Examples*

learn html

This tutorial series is designed for beginners who are interested in learning HTML. It will teach you the basics of HTML and CSS. This is a comprehensive guide to help you learn the basics of HTML and CSS. It will teach you how to create your own website, blog, or online store using HTML and CSS.

The thing to keep in mind is that HTML and CSS are all about separating the content (HTML) and the presentation (CSS). HTML is nothing more than fancy structured content and the visual formatting of that content will come later when we tackle CSS.

YouTube video

If you compare some of the information out there, information such as using deprecated or less reliable methods to interact with HTML elements, might not agree with what you learned from other tutorials. Many methods are unnecessary, non-standard, or just plain bad practice. To get the most out of the things you do, it'll help to be mindful when carrying them out. The end result will always be much better for it.

HTML Introduction

html HTML (Hypertext Markup Language) is a markup language that defines what a document is to be displayed as, how it should be structured, and what elements it should contain.

HTML documents are read by computers using software called web browsers. This software interprets HTML documents and displays them on screen in various formats such as text or graphics.

Example Explained

  • The DOCTYPE declaration defines the document type

  • The text between <html> and </html> describes the web page

  • The text between <body> and </body> is the visible page content

  • The text between <h1> and </h1> is displayed as a heading

  • The text between <p> and </p> is displayed as a paragraph

What is HTML simple definition?

HTML is a language for describing web pages. It is a markup language used for creating web pages. Its purpose is to provide an easy way for people to create text-based web pages and content more structured than plain text. It also allows web developers to create interactive, dynamic websites that can present a variety of information in an orderly fashion.

  • HTML stands for Hyper Text Markup Language

  • HTML is a markup language

  • A markup language is a set of markup tags

  • The tags describe document content

  • HTML documents contain HTML tags and plain text

  • HTML documents are also called web pages

HTML Tags HTML markup tags are usually called HTML tags, HTML Tags are the basic building blocks of any web page. These tags allow web designers and developers to create a website by giving them a way to add features such as text, images, links, and more.

  • HTML tags are keywords (tag names) surrounded by angle brackets like <html>

  • HTML tags normally come in pairs like <b> and </b>

  • The first tag in a pair is the start tag, the second tag is the end tag

  • The end tag is written like the start tag, with a forward slash before the tag name

  • Start and end tags are also called opening tags and closing tags

<tagname>content</tagname>

HTML Elements “HTML tags” and “HTML elements” are often used to describe the same thing. But strictly speaking, an HTML element is everything between the start tag and the end tag, including the tags: HTML Element:

<p>This is a paragraph.</p>

Web Browsers The purpose of a web browser (such as Google Chrome, Internet Explorer, Firefox, Safari) is to read HTML documents and display them as web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page:

HTML Example!

<!DOCTYPE html> <html> <body><h1>My First Heading</h1>

<p>My first paragraph.</p>

</body> </html>

If you want to practice your tags, try doing the following exercise which doesn't focus on a specific tag. If you see any mistakes, please tell me in the comments or via email so that I can update this post.

You will learn about them in next!


HTML Headings

Headings are used to identify the level of importance of a section.They are also used to create a hierarchy in the document. HTML headings are defined with the <h1> to <h6> tags.

HTML headings are defined with the <h1> to <h6> tags.

<!DOCTYPE html>
<html>
<body>

<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>

</body>
</html>


HTML Lines

The <hr>tag creates a horizontal line in an HTML page.The hr element can be used to separate content:
<!DOCTYPE html>
<html>
<body>
<p>The hr tag defines a horizontal rule:</p>
<hr>
<p>This is a paragraph.</p>
<hr>
<p>This is a paragraph.</p>
<hr>
<p>This is a paragraph.</p>
</body>
</html>


HTML Paragraphs

HTML paragraphs are defined with the <p> tag.

<!DOCTYPE html>
<html>
<body>

<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>

</body>
</html> 

HTML Links

HTML links are defined with the <a> tag.

<!DOCTYPE html>
<html>
<body>

<a href=”http://freebloggingtricks.com”>
This is a link</a>

</body>
</html>

 
HTML Images

HTML images are defined with the <img> tag.

<!DOCTYPE html>
<html>
<body>

<img src=”http://freebloggingtricks.com/wp-content/uploads/2013/11/logo.png” width=”400″ height=”142″></body>
</html>


HTML Comments

Comments can be inserted into the HTML code to make it more readable and understandable. Comments are ignored by the browser and are not displayed.
Comments are written like this:
<!DOCTYPE html>
<html>
<body><!–This comment will not be displayed–>
<p>This is a regular paragraph</p></body>
</html>

HTML Paragraphs

HTML Paragraphs are a way to create paragraphs in HTML. They are used to create a paragraph with a single line break. Paragraphs are defined with the <p> tag.

 <!DOCTYPE html>

<html>

<body>

<p>This is a paragraph.</p>

<p>This is a paragraph.</p>

<p>This is a paragraph.</p>

</body>

</html>

Note: Browsers automatically add an empty line before and after a paragraph.

Don’t Forget the End Tag

Most browsers will display HTML correctly even if you forget the end tag:

<!DOCTYPE html> <html> <body><p>This is a paragraph. <p>This is a paragraph. <p>This is a paragraph.

<p>Don’t forget to close your HTML tags!</p>

</body> </html>

 Note: Future version of HTML will not allow you to skip end tags.

HTML Line Breaks

Use the <br> tag if you want a line break (a new line) without starting a new paragraph:

<!DOCTYPE html> <html> <body><p>This is<br>a para<br>graph with line breaks</p>

</body> </html>

Note: The <br> element is an empty HTML element. It has no end tag.


HTML Table Headers

HTML table headers are used to create a header for a table. They are created by using the tag and then adding the header text in between the opening and closing tags.

Header information in a table are defined with the <th> tag. All major browsers display the text in the <th> element as bold and centered.

<table border=”1″> <tr> <th>Header 1</th> <th>Header 2</th> </tr> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </tr> </table>

Teach Yourself  by HTML Editor Tool.   How the HTML code above looks in your browser:

Header 1 Header 2
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2

HTML Table Tags

Tag Description
<table> Defines a table
<th> Defines a header cell in a table
<tr> Defines a row in a table
<td> Defines a cell in a table
<caption> Defines a table caption
<colgroup> Specifies a group of one or more columns in a table for formatting
<col> Specifies column properties for each column within a <colgroup> element
<thead> Groups the header content in a table
<tbody> Groups the body content in a table
<tfoot> Groups the footer content in a table

HTML Colors

HTML Colors are a set of colors that can be used in HTML documents. They are used to specify the foreground and background colors of an element. The color values for each color is specified by three hexadecimal digits, which represent the red, green, and blue components of the color.

Color Values

HTML colors are defined using a hexadecimal notation (HEX) for the combination of Red, Green, and Blue color values (RGB).

The lowest value that can be given to one of the light sources is 0 (in HEX: 00). The highest value is 255 (in HEX: FF).
HEX values are specified as 3 pairs of two-digit numbers, starting with a # sign.
Example
<!DOCTYPE html>
<html>
<body><p style=”background-color:#FFFF00″>
Color set by using hex value
</p><p style=”background-color:rgb(255,255,0)”>
Color set by using rgb value
</p><p style=”background-color:yellow”>
Color set by using color name
</p></body>
</html>

Web Safe Colors?

Some years ago, when computers supported max 256 different colors, a list of 216 “Web Safe Colors” was suggested as a Web standard, reserving 40 fixed system colors.
The 216 cross-browser color palette was created to ensure that all computers would display the colors correctly when running a 256 color palette.
This is not important today, since most computers can display millions of different colors. Anyway, here is the list:
000000 000033 000066 000099 0000CC 0000FF
003300 003333 003366 003399 0033CC 0033FF
006600 006633 006666 006699 0066CC 0066FF
009900 009933 009966 009999 0099CC 0099FF
00CC00 00CC33 00CC66 00CC99 00CCCC 00CCFF
00FF00 00FF33 00FF66 00FF99 00FFCC 00FFFF
330000 330033 330066 330099 3300CC 3300FF
333300 333333 333366 333399 3333CC 3333FF
336600 336633 336666 336699 3366CC 3366FF
339900 339933 339966 339999 3399CC 3399FF
33CC00 33CC33 33CC66 33CC99 33CCCC 33CCFF
33FF00 33FF33 33FF66 33FF99 33FFCC 33FFFF
660000 660033 660066 660099 6600CC 6600FF
663300 663333 663366 663399 6633CC 6633FF
666600 666633 666666 666699 6666CC 6666FF
669900 669933 669966 669999 6699CC 6699FF
66CC00 66CC33 66CC66 66CC99 66CCCC 66CCFF
66FF00 66FF33 66FF66 66FF99 66FFCC 66FFFF
990000 990033 990066 990099 9900CC 9900FF
993300 993333 993366 993399 9933CC 9933FF
996600 996633 996666 996699 9966CC 9966FF
999900 999933 999966 999999 9999CC 9999FF
99CC00 99CC33 99CC66 99CC99 99CCCC 99CCFF
99FF00 99FF33 99FF66 99FF99 99FFCC 99FFFF
CC0000 CC0033 CC0066 CC0099 CC00CC CC00FF
CC3300 CC3333 CC3366 CC3399 CC33CC CC33FF
CC6600 CC6633 CC6666 CC6699 CC66CC CC66FF
CC9900 CC9933 CC9966 CC9999 CC99CC CC99FF
CCCC00 CCCC33 CCCC66 CCCC99 CCCCCC CCCCFF
CCFF00 CCFF33 CCFF66 CCFF99 CCFFCC CCFFFF
FF0000 FF0033 FF0066 FF0099 FF00CC FF00FF
FF3300 FF3333 FF3366 FF3399 FF33CC FF33FF
FF6600 FF6633 FF6666 FF6699 FF66CC FF66FF
FF9900 FF9933 FF9966 FF9999 FF99CC FF99FF
FFCC00 FFCC33 FFCC66 FFCC99 FFCCCC FFCCFF
FFFF00 FFFF33 FFFF66 FFFF99 FFFFCC FFFFFF

HTML color names

HTML color names are a set of unique, human-readable names for colors. They are used in HTML documents to specify the colors of text and backgrounds.They are used in HTML documents to specify the colors of text and backgrounds. The list is maintained by the World Wide Web Consortium (W3C) and is based on the X11 Color System developed by MIT in 1984.

Color Names Supported by All Browsers

147 color names are defined in the HTML and CSS color specification (17 standard colors plus 130 more). The table below lists them all, along with their hexadecimal values.

Tip: The 17 standard colors are: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, orange, purple, red, silver, teal, white, and yellow.


HTML editors

HTML editors are a type of software that helps web designers and developers to create and edit HTML code. They are used for creating websites, blogs, landing pages, and other web content.

What do I need to create HTML?

You can create HTML without much difficulty and need pretty much anything. Programmers don't use special hardware or software to do it, so it's easy!

Here is what you need:

  • Computer

  • Text or HTML editor. Most computers already have a text editor and you can easily create HTML files using a text editor. Having said that, there are definite benefits to be gained in downloading an HTML editor. If you want the best HTML editor, and you don’t mind paying money for it, you can’t go past Adobe Dreamweaver. Dreamweaver is probably the best HTML editor available, and you can download a trial version for starters. If you don’t have the cash to purchase an editor, you can always download a free one. Examples include SeaMonkey, Coffee Cup (Windows) and TextPad (Windows). If you don’t have an HTML editor, and you don’t want to download one just now, a text editor is fine. Most computers already have a text editor. Examples of text editors include Notepad (for Windows), Pico (for Linux), or Simpletext/Text Edit/Text Wrangler (Mac).

  • Web Browser. For example, Chrome, Internet Explorer or Firefox.

Do I need to be online?

No, you do not need to be online to create web pages. You can create web pages on your local machine. You only need to go online when you want to publish your web page to the web – this bit comes later. The next lesson will show you how to create a web page in less than 5 minutes.

However, for learning HTML we recommend a text editor like Notepad (PC) or TextEdit (Mac). We believe using a simple text editor is a good way to learn HTML. Follow the 4 steps below to create your first web page with Notepad.


Step 1: Start Notepad
To start Notepad go to:
Start
All Programs
Accessories
Notepad


Step 2: Edit Your HTML with Notepad
Type your HTML code will into your Notepad:

HTML editor

Step 3: Save Your HTML
Select Save as.. in Notepad’s file menu.
When you save an HTML file, you can use either the .htm or the .html file extension. There is no difference, it is entirely up to you.
Save the file in a folder that is easy to remember, like FreeBloggingTricks.


Step 4: Run the HTML in Your Browser
Start your web browser and open your html file from the FileOpen menu, or just browse the folder and double-click your HTML file.
The result should look much like this:

HTML editors

HTML text formatting

HTML text formatting is used to control the layout and appearance of text on web pages. It can be used to make text bold, italic, underlined, or centered.

The most common use of HTML text formatting is to make it easier for people with visual impairments to read content on the web.

HTML Formatting Tags:

HTML uses tags like <b> and <i> for formatting output, like bold or italic text.
These HTML tags are called formatting tags (look at the bottom of this page for a complete reference).
Often <strong> renders as <b>, and <em> renders as <i>.However, there is a difference in the meaning of these tags:

<b> or <i> defines bold or italic text only.

<strong> or <em> means that you want the text to be rendered in a way that the user understands as “important”. Today, all major browsers render strong as bold and em as italics. However, if a browser one day wants to make a text highlighted with the strong feature, it might be cursive for example and not bold!

Example:

<!DOCTYPE html>
<html>
<body>

<p><b>This text is bold</b></p>
<p><strong>This text is strong</strong></p>
<p><i>This text is italic</i></p>
<p><em>This text is emphasized</em></p>
<p><code>This is computer output</code></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>

</body>
</html>


HTML lists

HTML lists are a great way to present information in a visually appealing way. They are also easy to create and maintain.

It can be used for many purposes, such as:

  • Presenting data in a list format

  • Creating navigation menus

  • Creating tabular data

An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.

The list items are marked with bullets (typically small black circles).

<ul> <li>Coffee</li> <li>Milk</li> </ul>

How the HTML code above looks in a browser:

  • Coffee

  • Milk

HTML Ordered Lists

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.

The list items are marked with numbers.

<ol> <li>Coffee</li> <li>Milk</li> </ol>

How the HTML code above looks in a browser:

  1. Coffee

  2. Milk

HTML Definition Lists

A definition list is a list of items, with a description of each item.

The <dl> tag defines a definition list.

The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item in the list):

<dl> <dt>Coffee</dt> <dd>- black hot drink</dd> <dt>Milk</dt> <dd>- white cold drink</dd> </dl>

How the HTML code above looks in a browser:

Coffee- black hot drinkMilk- white cold drink

Tip: Inside a list item you can put text, line breaks, images, links, other lists, etc.


HTML Blocks

HTML blocks are a new way of writing content that is becoming more and more popular. They are used to create a section of content that is not part of the main flow.

HTML blocks can be used for many purposes, such as:

  • Creating a sidebar or footer on your website

  • Creating an article with multiple sections

  • Creating a blog post with multiple sections

Most HTML element definitions state that they'll either begin or end a new line when displayed in a browser. They're normally formed as a block-level element or as an inline element.

Examples: <h1>, <p>, <ul>, <table>

HTML Inline Elements Inline elements are normally displayed without starting a new line. Examples: <b>, <td>, <a>, <img>

The HTML <div> Element The HTML <div> element is a block level element that can be used as a container for grouping other HTML elements. The <div> element has no special meaning. Except that, because it is a block level element, the browser will display a line break before and after it. When used together with CSS, the <div> element can be used to set style attributes to large blocks of content. Another common use of the <div> element, is for document layout. It replaces the “old way” of defining layout using tables. Using tables is not the correct use of the <table> element. The purpose of the <table> element is to display tabular data.

The HTML <span> Element The HTML <span> element is an inline element that can be used as a container for text. The <span> element has no special meaning. When used together with CSS, the <span> element can be used to set style attributes to parts of the text.


HTML Links

HTML Links are a type of hyperlink that is created by using the HTML markup language. They are used to link to other webpages, files, or resources on the same website.

HTML Links can be created in two ways:

1) Using an anchor tag with a URL: Link text

2) Using an anchor tag with a name attribute:Link text

HTML Link Syntax:

The HTML code for a link is simple. It looks like this:

<a href=”url“>Link text</a>

The href attribute specifies the destination of a link.

Example

<a href=”http://freebloggingtricks.com/”>Visit FreeBloggingTricks.com</a>

which will display like this: Visit FreeBloggingTricks.com

Clicking on this hyperlink will send the user to FBT’ homepage.

Tip: The “Link text” doesn’t have to be text. It can be an image or any other HTML element.

HTML Links – The target Attribute

The target attribute specifies where to open the linked document.

The example below will open the linked document in a new browser window or a new tab:

<!DOCTYPE html>

<html>

<body>

<a href=”http://freebloggingtricks.com/” target=”_blank”>Visit FreeBloggingTricks.com!</a>

<p>If you set the target attribute to “_blank”, the link will open in a new browser window/tab.</p>

</body>

</html>

HTML Links – The id Attribute

The id attribute can be used to create a bookmark inside an HTML document.

Tip: Bookmarks are not displayed in any special way. They are invisible to the reader.

Example

An anchor with an id inside an HTML document:

<a id=”tips”>Useful Tips Section</a>

Create a link to the “Useful Tips Section” inside the same document:

<a href=”#tips”>Visit the Useful Tips Section</a>

Or, create a link to the “Useful Tips Section” from another page:

<a href=”http://freebloggingtricks.com/html_links.htm#tips”>

Visit the Useful Tips Section</a>


HTML JavaScript

The HTML <noscript> Tag

The <noscript> tag is used to provide an alternate content for users that have disabled scripts in their browser or have a browser that doesn’t support client-side scripting.

The <noscript> element can contain all the elements that you can find inside the <body> element of a normal HTML page.

The content inside the <noscript> element will only be displayed if scripts are not supported, or are disabled in the user’s browser:

Example 

<!DOCTYPE html> <html> <body>

<script> document.write(“Hello World!”) </script> <noscript>Sorry, your browser does not support JavaScript!</noscript>

<p>A browser without support for JavaScript will show the text in the noscript element.</p>

</body> </html>

The HTML <noscript> Tag
The <noscript> tag is used to provide an alternate content for users that have disabled scripts in their browser or have a browser that doesn’t support client-side scripting.
The <noscript> element can contain all the elements that you can find inside the <body> element of a normal HTML page.
The content inside the <noscript> element will only be displayed if scripts are not supported, or are disabled in the user’s browser:
Example 
<!DOCTYPE html>
<html>
<body>

<script>
document.write(“Hello World!”)
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>

<p>A browser without support for JavaScript will show the text in the noscript element.</p>

</body>
</html>

A Taste of JavaScript

Here are some examples of what JavaScript can do:
JavaScript can write directly into the HTML output stream:
<!DOCTYPE html>
<html>
<body><p>
JavaScript can write directly into the HTML output stream:
</p><script>
document.write(“<h1>This is a heading</h1>”);
document.write(“<p>This is a paragraph.</p>”);
</script><p>
You can only use <strong>document.write</strong> in the HTML output.
If you use it after the document has loaded (e.g. in a function), the whole document will be overwritten.
</p></body>
</html>
JavaScript can react to events:
<!DOCTYPE html>
<html>
<body><h1>My First JavaScript</h1><p id=”demo”>
JavaScript can react to events. Like the click of a button.
</p><script>
function myFunction()
{
document.getElementById(“demo”).innerHTML=”Hello JavaScript!”;
}
</script><button type=”button” onclick=”myFunction()”>Click Me!</button></body>
</html>
JavaScript can manipulate HTML styles:
<!DOCTYPE html>
<html>
<body><h1>My First JavaScript</h1><p id=”demo”>
JavaScript can change the style of an HTML element.
</p><script>
function myFunction()
{
x=document.getElementById(“demo”) // Find the element
x.style.color=”#ff0000″;          // Change the style
}
</script><button type=”button” onclick=”myFunction()”>Click Me!</button></body>
</html>

How can we insert JavaScript in HTML?

JavaScript is an interpreted computer programming language that can be embedded in HTML, or used separately from it. It provides dynamic behavior, event handling, and object-oriented programming with data structures such as objects, arrays, and strings.

JavaScript is not just limited to web pages anymore; it can also be used in other software applications such as desktop applications or games. It has become an important part of modern software development because it allows programmers to create interactive experiences without having to learn complex programming languages like C++ or Java.


HTML elements

HTML elements are the building blocks of HTML documents. They are the fundamental units of an HTML document, which can be combined to create more complex structures.

HTML Element Syntax

  • An HTML element starts with a start tag / opening tag

  • An HTML element ends with an end tag / closing tag

  • The element content is everything between the start and the end tag

  • Some HTML elements have empty content

  • Empty elements are closed in the start tag

  • Most HTML elements can have attributes

Nested HTML Elements
Most HTML elements can be nested (can contain other HTML elements).
HTML documents consist of nested HTML elements.

HTML Document Example
<!DOCTYPE html>
<html><body>
<p>This is my first paragraph.</p>
</body></html>
The example above contains 3 HTML elements.

HTML Example Explained
The <p> element:
<p>This is my first paragraph.</p>
The <p> element defines a paragraph in the HTML document.
The element has a start tag <p> and an end tag </p>.
The element content is: This is my first paragraph.

The <body> element:

<body>
<p>This is my first paragraph.</p>
</body>
The <body> element defines the body of the HTML document.
The element has a start tag <body> and an end tag </body>.
The element content is another HTML element (a p element)

The <html> element:

<html><body>
<p>This is my first paragraph.</p>
</body></html>
The <html> element defines the whole HTML document.
The element has a start tag <html> and an end tag </html>.
The element content is another HTML element (the body element).

Don’t Forget the End Tag
Some HTML elements might display correctly even if you forget the end tag:
<p>This is a paragraph
<p>This is a paragraph
The example above works in most browsers, because the closing tag is considered optional.
Never rely on this. Many HTML elements will produce unexpected results and/or errors if you forget the end tag .

Empty HTML Elements

HTML elements with no content are called empty elements.
<br> is an empty element without a closing tag (the <br> tag defines a line break).
Tip: In XHTML, all elements must be closed. Adding a slash inside the start tag, like <br />, is the proper way of closing empty elements in XHTML (and XML).

XHTML

XHTML is an XML-based markup language that was developed by the World Wide Web Consortium (W3C) in 2000.

XHTML has been widely adopted as a standard for creating web pages and it has been supported by all major browsers since its release. However, HTML still remains popular because it is easier to use and understand for most people.

XHTML website forms

Using XHTML forms website
XHTML – Exteded HyperText Markup Language

XHTML is a markup language. XHTML file has extension html or htm. Now, the website uses just XHTML (formerly HTML), which is based on a general standard for exchanging XML data. XHTML describes the importance of content (comparison of HTML and XHTML). But, it is not important.

XHTML Elements and tags

xhtml-prntscr

v creates a document with tags. And that’s important. For example:

Normal text <strong> emphasized text </ strong>

What I wrote is now XHTML source code. The source code is written in a text editor (or Web page editor) and stored with the extension .html or .htm, such a document is then opened in an Internet browser (Internet Explorer, Mozilla Firefox …) And what is most important.

At the beginning of the bold text to insert a <strong> at the end of the closing </ strong>, the backslash is used to determine that it is a closing tag. Delimited text, including tags is called an element or element. Symbols are always written in small letters!
attributes


HTML Tip: Use Lowercase Tags

HTML tags are not case sensitive: <P> means the same as <p>. Many web sites use uppercase HTML tags.
FBT use lowercase tags because the World Wide Web Consortium (W3C) recommends lowercase in HTML 4, and demands lowercase tags in XHTML.

HTML Head

The HTML Head is the first section of an HTML document. It contains information about the document, such as the title, author, and date. It is a very important part of an HTML document. It contains information about the document, such as the title, author, and date.

The <head> element is a container for all the head elements. Elements inside <head> can include scripts, instruct the browser where to find style sheets, provide meta information, and more.

The following tags can be added to the head section: <title>, <style>, <meta>, <link>, <script>, <noscript>, and <base>.

The HTML <title> Element

The <title> tag defines the title of the document.

The <title> element is required in all HTML/XHTML documents.

The <title> element:

  • defines a title in the browser toolbar

  • provides a title for the page when it is added to favorites

  • displays a title for the page in search-engine results

A simplified HTML document:

<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head><body> The content of the document…… </body></html>


HTML Layouts

HTML layouts are the most common type of layout used in web design. They are also the most flexible and customizable layout type.

Most websites have put their content in multiple columns (formatted like a magazine or newspaper). Multiple columns are created by using <div> or <table> elements. CSS are used to position elements, or to create backgrounds or colorful look for the pages.

HTML Layouts – Using <div> Elements

The div element is a block level element used for grouping HTML elements.
The following example uses five div elements to create a multiple column layout, creating the same result as in the previous example:
Example
<!DOCTYPE html>
<html>
<body><div id=”container” style=”width:500px”><div id=”header” style=”background-color:#FFA500;”>
<h1 style=”margin-bottom:0;”>Main Title of Web Page</h1></div><div id=”menu” style=”background-color:#FFD700;height:200px;width:100px;float:left;”>
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript</div><div id=”content” style=”background-color:#EEEEEE;height:200px;width:400px;float:left;”>
Content goes here</div><div id=”footer” style=”background-color:#FFA500;clear:both;text-align:center;”>
Copyright © FreeBloggingTricks.com</div>

</div>

</body>
</html>

HTML Layouts – Using Tables

A simple way of creating layouts is by using the HTML <table> tag.
Multiple columns are created by using <div> or <table> elements. CSS are used to position elements, or to create backgrounds or colorful look for the pages.
The following example uses a table with 3 rows and 2 columns – the first and last row spans both columns using the colspan attribute:
Example
<!DOCTYPE html>
<html>
<body><table width=”500″ border=”0″>
<tr>
<td colspan=”2″ style=”background-color:#FFA500;”>
<h1>Main Title of Web Page</h1>
</td>
</tr><tr>
<td style=”background-color:#FFD700;width:100px;”>
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript
</td>
<td style=”background-color:#EEEEEE;height:200px;width:400px;”>
Content goes here</td>
</tr><tr>
<td colspan=”2″ style=”background-color:#FFA500;text-align:center;”>
Copyright © FreeBloggingTricks.com</td>
</tr>
</table></body>
</html>

HTML Entities

HTML entities are a set of codes that can be used in HTML to represent special characters. They are used to make the text more readable and accessible.

Some characters are reserved in HTML. It is not possible to use the less than (<) or greater than (>) signs in your text, because the browser will mix them with tags

To actually display reserved characters, we must use character entities in the HTML source code. A character entity looks like this:

&entity_name; OR &#entity_number;

To display a less than sign we must write: < or <

HTML Useful Character Entities

Note: Entity names are case sensitive!
Result Description Entity Name Entity Number
non-breaking space  
< less than < <
> greater than > >
& ampersand & &
¢ cent ¢ ¢
£ pound £ £
¥ yen ¥ ¥
euro
§ section § §
© copyright © ©
® registered trademark ® ®
trademark

HTML attributes

HTML attributes are the most basic building blocks of HTML. They are used to specify the appearance and behavior of an HTML element. Attributes can be used to specify the appearance and behavior of an HTML element. Attributes can also be used to provide additional information about an element, such as its title or author.

HTML attributes are the most basic building blocks of HTML. They are used to specify the appearance and behavior of an HTML element.

  • HTML elements can have attributes

  • Attributes provide additional information about an element

  • Attributes are always specified in the start tag

  • Attributes come in name/value pairs like: name=”value”

Attribute Example

HTML links are defined with the <a> tag. The link address is specified in the href attribute:

<!DOCTYPE html>
<html>
<body>

<a href=”http://www.freebloggingtricks.com”>
This is a link</a>

</body>
</html>


HTML CSS

What is the difference between HTML and CSS?

HTML and CSS are the two most important languages for web design. They are used to create a website's layout and style. HTML is the language of content, while CSS is the language of design. HTML is a markup language that tells browsers how to display content on a web page, while CSS is a stylesheet language that tells browsers how to display content on a web page.

Are HTML and CSS programming languages?

Yes, both HTML and CSS are programming languages. However, there are some key differences. HTML is much more focused on the presentation of webpages while CSS focuses on the layout and design of web pages.

Styling HTML with CSS:

CSS was introduced together with HTML 4, to provide a better way to style HTML elements. CSS can be added to HTML in the following ways:
  • Inline – using the style attribute in HTML elements
  • Internal – using the <style> element in the <head> section
  • External – using an external CSS file
The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files.
However, in this HTML tutorial we will introduce you to CSS using the style attribute. This is done to simplify the examples. It also makes it easier for you to edit the code and try it yourself.

Inline Styles

An inline style can be used if a unique style is to be applied to one single occurrence of an element.
<p style=”color:blue;margin-left:20px;”>This is a paragraph.</p>

HTML Style Example – Background Color

The background-color property defines the background color for an element:
<!DOCTYPE html>
<html>
<body style=”background-color:yellow;”>
<h2 style=”background-color:red;”>This is a heading</h2>
<p style=”background-color:green;”>This is a paragraph.</p>
</body>
</html>

HTML Forms and Input

HTML forms are a way to collect information from the user. They are used in web applications and websites to collect data from users.

HTML Forms

HTML forms are used to pass data to a server.

An HTML form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A form can also contain select lists, textarea, fieldset, legend, and label elements.

The <form> tag is used to create an HTML form:

<form>
.
input elements
.
</form>

HTML Forms – The Input Element

The most important form element is the <input> element.
The <input> element is used to select user information.
An <input> element can vary in many ways, depending on the type attribute. An <input> element can be of type text field, checkbox, password, radio button, submit button, and more.
The most common input types are described below.

Text Fields
<input type=”text”> defines a one-line input field that a user can enter text into:
<form>
First name: <input type=”text” name=”firstname”><br>
Last name: <input type=”text” name=”lastname”>
</form>
How the HTML code above looks in a browser:
First name:
Last name:

Note: The form itself is not visible. Also note that the default width of a text field is 20 characters.


Password Field
<input type=”password”> defines a password field:
<form>
Password: <input type=”password” name=”pwd”>
</form>
How the HTML code above looks in a browser:
Password: 
Note: The characters in a password field are masked (shown as asterisks or circles).

Radio Buttons
<input type=”radio”> defines a radio button. Radio buttons let a user select ONLY ONE of a limited number of choices:
<form>
<input type=”radio” name=”sex” value=”male”>Male<br>
<input type=”radio” name=”sex” value=”female”>Female
</form>
How the HTML code above looks in a browser:
Male
Female

Checkboxes
<input type=”checkbox”> defines a checkbox. Checkboxes let a user select ZERO or MORE options of a limited number of choices.
<form>
<input type=”checkbox” name=”vehicle” value=”Bike”>I can read<br>
<input type=”checkbox” name=”vehicle” value=”Car”>I can write</form>
How the HTML code above looks in a browser:

Submit Button
<input type=”submit”> defines a submit button.
A submit button is used to send form data to a server. The data is sent to the page specified in the form’s action attribute. The file defined in the action attribute usually does something with the received input:
<form name=”input” action=”html_form_action.asp” method=”get”>
Username: <input type=”text” name=”user”>
<input type=”submit” value=”Submit”>
</form>
How the HTML code above looks in a browser:
Username:
If you type some characters in the text field above, and click the “Submit” button, the browser will send your input to a page called “html_form_action.asp”. The page will show you the received input.

HTML URL Encode

HTML URL Encode is a function that converts a URL into an HTML string. It is used to encode the URLs in HTML documents.

Common URL Schemes

The table below lists some common schemes:

Scheme Short for…. Which pages will the scheme be used for…
http HyperText Transfer Protocol Common web pages starts with http://. Not encrypted
https Secure HyperText Transfer Protocol Secure web pages. All information exchanged are encrypted
ftp File Transfer Protocol For downloading or uploading files to a website. Useful for domain maintenance
file A file on your computer

URL Encoding Examples

Character URL-encoding
%80
£ %A3
© %A9
® %AE
À %C0
Á %C1
 %C2
à %C3
Ä %C4
Å %C5

What does %2f mean in URL?

Simply represents the “/” character in your URL.

URL-encoding from %00 to %8f

ASCII Value URL-encode ASCII Value URL-encode ASCII Value URL-encode
%00 0 %30 ` %60
%01 1 %31 a %61
%02 2 %32 b %62
%03 3 %33 c %63
%04 4 %34 d %64
%05 5 %35 e %65
%06 6 %36 f %66
%07 7 %37 g %67
backspace %08 8 %38 h %68
tab %09 9 %39 i %69
linefeed %0a : %3a j %6a
%0b ; %3b k %6b
%0c < %3c l %6c
c return %0d = %3d m %6d
%0e > %3e n %6e
%0f ? %3f o %6f
%10 @ %40 p %70
%11 A %41 q %71
%12 B %42 r %72
%13 C %43 s %73
%14 D %44 t %74
%15 E %45 u %75
%16 F %46 v %76
%17 G %47 w %77
%18 H %48 x %78
%19 I %49 y %79
%1a J %4a z %7a
%1b K %4b { %7b
%1c L %4c | %7c
%1d M %4d } %7d
%1e N %4e ~ %7e
%1f O %4f %7f
space %20 P %50 %80
! %21 Q %51 %81
%22 R %52 %82
# %23 S %53 ƒ %83
$ %24 T %54 %84
% %25 U %55 %85
& %26 V %56 %86
%27 W %57 %87
( %28 X %58 ˆ %88
) %29 Y %59 %89
* %2a Z %5a Š %8a
+ %2b [ %5b %8b
, %2c \ %5c Π%8c
%2d ] %5d %8d
. %2e ^ %5e Ž %8e
/ %2f _ %5f %8f

URL-encoding from %90 to %ff

ASCII Value URL-encode ASCII Value URL-encode ASCII Value URL-encode
%90 %c0 %f0
%91 %c1 %f1
%92 %c2 %f2
%93 %c3 %f3
%94 %c4 %f4
%95 %c5 %f5
%96 %c6 %f6
%97 %c7 %f7
˜ %98 %c8 %f8
%99 %c9 %f9
š %9a %ca %fa
%9b %cb %fb
œ %9c %cc %fc
%9d %cd %fd
ž %9e %ce %fe
Ÿ %9f %cf %ff
%a0 %d0
%a1 %d1
%a2 %d2
%a3 %d3
%a4 %d4
%a5 %d5
| %a6 %d6
%a7 %d7
%a8 %d8
%a9 %d9
%aa %da
%ab %db
%ac %dc
%ad %dd
%ae %de
%af %df
%b0 %e0
%b1 %e1
%b2 %e2
%b3 %e3
%b4 %e4
%b5 %e5
%b6 %e6
%b7 %e7
%b8 %e8
%b9 %e9
%ba %ea
%bb %eb
%bc %ec
%bd %ed
%be %ee
%bf %ef

HTML Images

HTML Images are images that are embedded in HTML code. They can be used to display images on a website without using any third-party software. It are used for many purposes, such as displaying images on a website, creating banners, and adding icons to websites.

The <img> tag is empty, which means that it contains attributes only, and has no closing tag.

To display an image on a page, you need to use the src attribute. Src stands for “source”. The value of the src attribute is the URL of the image you want to display.

Syntax for defining an image:

<img src=”url” alt=”some_text“>

HTML Images – The Alt Attribute The required alt attribute specifies an alternate text for an image, if the image cannot be displayed. The value of the alt attribute is an author-defined text:

<img src=”boat.gif” alt=”Big Boat”>

HTML Images – Set Height and Width of an Image The height and width attributes are used to specify the height and width of an image. The attribute values are specified in pixels by default:

<img src=”pulpit.jpg” alt=”Pulpit rock” width=”304″ height=”228″>


HTML Iframes

HTML Iframes are a way to embed content from other websites into your website. They are used for displaying images, videos, and other media.

Syntax for adding an iframe:

<iframe src=”URL“></iframe>

The URL points to the location of the separate page.

Iframe – Set Height and Width

The height and width attributes are used to specify the height and width of the iframe.

The attribute values are specified in pixels by default, but they can also be in percent (like “80%”).

iframe Example

<!DOCTYPE html>
<html>
<body><iframe src=”demo_iframe.htm” width=”200″ height=”200″></iframe>

<p>Some older browsers don’t support iframes.</p>
<p>If they don’t, the iframe will not be visible.</p>

</body>
</html>

Iframe – Remove the Border
The frameborder attribute specifies whether or not to display a border around the iframe.
Set the attribute value to “0″ to remove the border:
Example
<!DOCTYPE html>
<html>
<body><iframe src=”demo_iframe.htm” frameborder=”0″></iframe><p>Some older browsers don’t support iframes.</p>
<p>If they don’t, the iframe will not be visible.</p></body>
</html>

Use iframe as a Target for a Link

An iframe can be used as the target frame for a link.
The target attribute of a link must refer to the name attribute of the iframe:
Example
<!DOCTYPE html>
<html>
<body><iframe src=”demo_iframe.htm” name=”iframe_a”></iframe>
<p><a href=”http://freebloggingtricks.com” target=”iframe_a”>FreeBloggingTricks.com</a></p><p><b>Note:</b> Because the target of the link matches the name of the iframe, the link will open in the iframe.</p></body>
</html>

HTML Quick List

HTML Quick List is a tool that helps you create a list of links in HTML format. It is an easy-to-use tool that can be used by anyone who has basic knowledge of HTML.

HTML Basic Document

<!DOCTYPE html>
<html>
<head>
<title>Title of document goes here</title>
</head>
<body>
Visible text goes here…
</body> </html>

Html Basic Tags

<h1>Largest Heading</h1>
<h2> . . . </h2>
<h3> . . . </h3>
<h4> . . . </h4>
<h5> . . . </h5>
<h6>Smallest Heading</h6>

<p>This is a paragraph.</p>
<br> (line break)
<hr> (horizontal rule)
<!– This is a comment –>

 

Formatting

<b>Bold text</b>
<code>Computer code</code>
<em>Emphasized text</em>
<i>Italic text</i>
<kbd>Keyboard input</kbd>
<pre>Preformatted text</pre>
<small>Smaller text</small>
<strong>Important text</strong>

<abbr> (abbreviation)
<address> (contact information)
<bdo> (text direction)
<blockquote> (a section quoted from another source)
<cite> (title of a work)
<del> (deleted text)
<ins> (inserted text)
<sub> (subscripted text)
<sup> (superscripted text)

Links

Ordinary link: <a href=”http://www.example.com/”>Link-text goes here</a>
Image-link: <a href=”http://www.example.com/”><img src=”URL” alt=”Alternate Text”></a>
Mailto link: <a href=”mailto:[email protected]”>Send e-mail</a>Bookmark:
<a id=”tips”>Tips Section</a>
<a href=”#tips”>Jump to the Tips Section</a>

Images

<img src=”URL” alt=”Alternate Text” height=”42″ width=”42″>

Styles/Sections

<style type=”text/css”>
h1 {color:red;}
p {color:blue;}
</style>

<div>A block-level section in a document</div>
<span>An inline section in a document</span>

Unordered list

<ul>
<li>Item</li>
<li>Item</li>
</ul>

Ordered list

<ol>
<li>First item</li>
<li>Second item</li>
</ol>

Definition list

<dl>
<dt>Item 1</dt>
<dd>Describe item 1</dd>
<dt>Item 2</dt>
<dd>Describe item 2</dd>
</dl>

Tables

<table border=”1″>
<tr>
<th>table header</th>
<th>table header</th>
</tr>
<tr>
<td>table data</td>
<td>table data</td>
</tr>
</table>

Iframe

<iframe src=”demo_iframe.htm”></iframe>

Forms

<form action=”demo_form.asp” method=”post/get”> <input type=”text” name=”email” size=”40″ maxlength=”50″>
<input type=”password”>
<input type=”checkbox” checked=”checked”>
<input type=”radio” checked=”checked”>
<input type=”submit” value=”Send”>
<input type=”reset”>
<input type=”hidden”>
<select>
<option>Apples</option>
<option selected=”selected”>Bananas</option>
<option>Cherries</option>
</select>
<textarea name=”comment” rows=”60″ cols=”20″></textarea>

</form>

Entities
< is the same as <
> is the same as >
© is the same as ©

blank

Written by Jason Striegel

C/C++, Java, Python, Linux developer for 18 years, A-Tech enthusiast love to share some useful tech hacks.