Skip to content

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

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.

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.

Contents

HTML Introduction

htmlHTML (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 1Header 2
row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2

HTML Table Tags

TagDescription
<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:
0000000000330000660000990000CC0000FF
0033000033330033660033990033CC0033FF
0066000066330066660066990066CC0066FF
0099000099330099660099990099CC0099FF
00CC0000CC3300CC6600CC9900CCCC00CCFF
00FF0000FF3300FF6600FF9900FFCC00FFFF
3300003300333300663300993300CC3300FF
3333003333333333663333993333CC3333FF
3366003366333366663366993366CC3366FF
3399003399333399663399993399CC3399FF
33CC0033CC3333CC6633CC9933CCCC33CCFF
33FF0033FF3333FF6633FF9933FFCC33FFFF
6600006600336600666600996600CC6600FF
6633006633336633666633996633CC6633FF
6666006666336666666666996666CC6666FF
6699006699336699666699996699CC6699FF
66CC0066CC3366CC6666CC9966CCCC66CCFF
66FF0066FF3366FF6666FF9966FFCC66FFFF
9900009900339900669900999900CC9900FF
9933009933339933669933999933CC9933FF
9966009966339966669966999966CC9966FF
9999009999339999669999999999CC9999FF
99CC0099CC3399CC6699CC9999CCCC99CCFF
99FF0099FF3399FF6699FF9999FFCC99FFFF
CC0000CC0033CC0066CC0099CC00CCCC00FF
CC3300CC3333CC3366CC3399CC33CCCC33FF
CC6600CC6633CC6666CC6699CC66CCCC66FF
CC9900CC9933CC9966CC9999CC99CCCC99FF
CCCC00CCCC33CCCC66CCCC99CCCCCCCCCCFF
CCFF00CCFF33CCFF66CCFF99CCFFCCCCFFFF
FF0000FF0033FF0066FF0099FF00CCFF00FF
FF3300FF3333FF3366FF3399FF33CCFF33FF
FF6600FF6633FF6666FF6699FF66CCFF66FF
FF9900FF9933FF9966FF9999FF99CCFF99FF
FFCC00FFCC33FFCC66FFCC99FFCCCCFFCCFF
FFFF00FFFF33FFFF66FFFF99FFFFCCFFFFFF

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!
ResultDescriptionEntity NameEntity 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:

SchemeShort for….Which pages will the scheme be used for…
httpHyperText Transfer ProtocolCommon web pages starts with http://. Not encrypted
httpsSecure HyperText Transfer ProtocolSecure web pages. All information exchanged are encrypted
ftpFile Transfer ProtocolFor downloading or uploading files to a website. Useful for domain maintenance
fileA file on your computer

URL Encoding Examples

CharacterURL-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 ValueURL-encodeASCII ValueURL-encodeASCII ValueURL-encode
%000%30`%60
%011%31a%61
%022%32b%62
%033%33c%63
%044%34d%64
%055%35e%65
%066%36f%66
%077%37g%67
backspace%088%38h%68
tab%099%39i%69
linefeed%0a:%3aj%6a
%0b;%3bk%6b
%0c<%3cl%6c
c return%0d=%3dm%6d
%0e>%3en%6e
%0f?%3fo%6f
%10@%40p%70
%11A%41q%71
%12B%42r%72
%13C%43s%73
%14D%44t%74
%15E%45u%75
%16F%46v%76
%17G%47w%77
%18H%48x%78
%19I%49y%79
%1aJ%4az%7a
%1bK%4b{%7b
%1cL%4c|%7c
%1dM%4d}%7d
%1eN%4e~%7e
%1fO%4f%7f
space%20P%50%80
!%21Q%51%81
%22R%52%82
#%23S%53ƒ%83
$%24T%54%84
%%25U%55%85
&%26V%56%86
%27W%57%87
(%28X%58ˆ%88
)%29Y%59%89
*%2aZ%5aŠ%8a
+%2b[%5b%8b
,%2c\%5cŒ%8c
%2d]%5d%8d
.%2e^%5eŽ%8e
/%2f_%5f%8f

URL-encoding from %90 to %ff

ASCII ValueURL-encodeASCII ValueURL-encodeASCII ValueURL-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 ©

nv-author-image

Michael

Michael Reddy is a tech enthusiast, entertainment buff, and avid traveler who loves exploring Linux and sharing unique insights with readers.