Disclosure: WHSR is reader-supported. When you buy through our links, we may earn a commission.
Basic HTML Guide for Dummies
Updated: 2022-06-02 / Article by: Jerry Low
HTML is the backbone of today's internet. Millions of websites together formed the internet. Where HTML is the building block of all these websites. Twenty years ago, even if you are just a hobby blogger, you had to know some web coding to protect yourself or to add a simple function to your site. But now there are so many editors and plugins available that even knowing the basics of HTML is no longer required.
The problem with this is that if you don’t know a few basics, you can easily get into real trouble in your blog and have to hire a pricey developer to fix what may be a minor problem. Not only that, but creating changes to your blog such as adding a custom text widget requires a little knowledge.
And if you are experiencing content layout doesn’t look right, HTML knowledge can get you back on track.
HTML is the abbreviation of Hyper Text Markup Language. It is the standard language for tagging contents for web browsers.
HTML is represented by “Elements”. Elements are also known as “Tags”.
2. Why is HTML needed?
Web browsers can only render a website when it is written in their supported language. HTML is the most common markup language and has the highest acceptance to web browsers.
That's why you need HTML.
3. Is HTML case sensitive?
HTML is not case sensitive. But the best practice is to write HTML with proper cases.
Steps for Creating Your First HTML File
You can create a basic HTML file using the Notepad on your computer. But it will be painful for writing many lines of codes.
You need a Code Editor. A good code editor will make it easier to write and organize large codes. I use and recommend Notepad++ (free and open-source) for writing web languages. There are other editors you may use like Sublime Text, Atom etc.
Here is what you need to do:
Install a code editor
Open it up
Create a new file
Save it as a .html file
You are ready to go!
1. Hello World!
Copy and paste the following code into your new HTML file and save it. Now run it on your web browser.
<title>My first web page</title>
Congrats! You have created your very first HTML file. You don't have to understand it at this point. We will cover it shortly.
Understanding HTML Structure
Every HTML file has a common naked structure. This is where everything starts. And every large page of codes will come to this structure after trimming down.
So let's try to understand it from the “Hello World!” code. The following elements are the mandatory parts for every HTML file.
<!DOCTYPE html> = It is a declaration to the browser that this is an HTML file. You must specify it before the <html> tag.
<html> </html> = This is the root element of an HTML file. Everything you write goes between <html> and </html>.
<head> </head> = This is the meta information part for a browser. Codes inside this tag have no visual output.
<body> </body> = This is the part that a web browser renders. What you exactly see on a website is the rendering of codes between <body> and </body>.
2. HTML Tags
HTML is the collaboration of hundreds of different tags. You need to learn how they work. You also have to make sure that they have used them in the right way.
HTML tags usually have an opening and a closing tag. The opening tag has the keyword surrounded by a less than (<) and a greater than (>) sign. The closing tag has everything same but an extra forward slash (/) after the less than (<) sign.
All the head tags go between <head> and </head>. They contain meta information for web browser and search engines. They basically have no visual output.
Title tag defines the title of a web page which is visible on the browser tab. This information is used by web programs and search engines. You can have highest one title per HTML file.
<title>My first web page</title>
Link tag links your HTML page with external resources. Its main use is linking HTML page with CSS stylesheets. It is a self-closing tag and doesn’t need the ending </link>. Here rel stands for relation with the file and src means the source.
Meta is another self-closing tag that provides meta information of an html file. Search engines and other web services use these information. Meta tags are a must if you want to optimize your page for search engines.
<meta name="description" content="This is the short description that search engines show"
The script tag is used for including a server-side script or making a link to an external script file. It can have two attributes in the opening tag. One is the type and another is the source (src).
Noscript tag works when scripts are disabled in a web browser. It makes a page compatible to them who don't allow scripts in their web browsers.
<noscript><p>Alas! Scripts are disabled.</p></noscript>
All the body tags go between <body> and </body>. They have visual outputs. This is where the most work is done. You have to use these tags to structure your main page content.
<h1> </h1> to <h6> </h6>
These are the heading tags. The most important heading is tagged with <h1> and the least important with <h6>. You should use them in the correct hierarchy.
<h1>This is a h1 heading</h1>
<h2>This is a h2 heading </h2>
<h3>This is a h3 heading </h3>
<h4>This is a h4 heading </h4>
<h5>This is a h5 heading </h5>
<h6>This is a h6 heading </h6>
Text in an html file can be formatted using many formatting tags. It will be necessary when you want to highlight a word or line from your content.
<p>You can highlight your text in many ways.</p>
<p>You can <strong>bold</strong>, <u>underline</u>, <em>italic</em>, <mark>mark</mark>, <sub>subscript</sub>, <sup>superscript</sup> and more!</p>
You can deviate some codes from rending using the comment tag. The code will show up in the source code but will not be rendered. The main use of this tag is for creating documentation of html files for future reference.
<! – <p>You can comment out any code by surrounding them in this way</p> – >
Other Important HTML Tags
Anchor is an invaluable tag which is used almost everywhere. You will not see any web page online without at least one anchor link.
The structure is same. It has an opening <a> and a closing part </a>. The text you want to anchor goes between <a> and </a>.
There are some attributes that define where and how the user goes after clicking on it.
ahref=” “ = It defines the destination link. The link goes between the double quotes.
target=” “ = It defines whether the URL will open in a new browser tab or in the same tab. target=”_blank” is for the new tab and target=”_self” is for opening in the same tab.
rel=” “ = It defines the relation of the current page with the linked page. If you don't trust the linked page, you can define rel=”nofollow”.
<p><a target="_blank" href="https://www.google.com/">Click here</a> to go to Google.
It will open in a new tab.</p>
<p><a target="_self" href="https://www.google.com/">Click here</a>.
It will also take you to Google but will open in the current tab.</p>
Image tag is another important tag without which you cannot imagine many image-based websites.
<img /> is a self-closing tag. It doesn't need the traditional closing like </img>. There are some attributes you need to know before you can use it correctly.
src=” “ = This is for defining the source link of the image. Put the link right between the double quotes.
alt=” “ = It stands for alternative text. When your image is not loading, this text will give users an idea about the missing image.
width=” “ = It defines the width of an image in pixels.
Height=” “ = It defines the height of an image in pixels.
<p>This is the Googleplex in August 2014.</p>
<p>This image has a width of 500 pixels and a height of 375 pixels.</p>
alt="Google's Headquarter in August 2014" width="500" height="375" />
Tips: Want to insert a clickable image? Wrap the image code with an <a> tag. See how it goes.
<ol> </ol> or <ul> </ul>
List tag is for creating a list of items. <ol> stands for ordered lists (numbered list) and <ul> stands for unordered lists (bullet points).
The list items inside the <ol> or <ul> is tagged with <li> </li>. li stands for list. You can have as many <li> as you want inside the parent <ol> or <ul> tag.
<p>This is an ordered list:</p>
<p>This is an unordered list:</p>
Table tag is for creating a table of data. There are a few inner level tags that defines table headers, rows and columns.
<table> </table> is the outer parent code. In this tag, <tr> stands for table row, <td> stands for table column and <th> stands for table header.
Form element is used for creating interactive forms for web pages. An HTML form contains several consecutive elements. For example: <label>, <input>, <textarea> etc.
The action attribute in form is very important. It points to a server-side or a third-party page for processing the information. For processing, you need to define a method first.
You can use either of two methods, get or post. Get sends all the information in the URL format where Post sends the information in the message body.
There are many types of input for forms. The very basic input type is text. It is written as <input type=”text”>. Types might also be radio, checkbox, email and so on. There should be a submit type input at the bottom for creating a submit button.
<label> tag is used for creating labels and associating them with inputs. The rule of associating labels with the inputs is that have the same value in for=” ” attribute of label and id=” ” attribute of input.
Note: I have pointed action to a null value because it was not connected to any server to process the information.
3. HTML Attributes
Attributes are one type of modifiers for HTML tags. They add new configurations to the HTML tags.
An attribute looks like attributename=” ” and sits in the opening HTML tag. The value of the attribute goes between the double quotes.
id=”” and class=””
id and class are the identifiers of HTML tags. Different names are designated to different HTML elements using identifiers. You can use one class identifier for multiple elements. But you cannot use one id identifier for multiple elements.
<h1 class="heading">This is the main title</h1>
href stands for Hypertext Reference. They point users to reference links. Anchor tag <a> uses href to send users to a destination URL.
src stands for source. It defines the source of a media or resource you are using in the HTML file. The source can be either local or third-party URL.
style attribute is often used in HTML tags. It does the job of CSS within the HTML tag. Your styling properties go between the double quotes.
<h2 style="color:red">This is another title</h2>
4. Code Display: Block vs Inline
Some elements always start on a new line and take the full available width. These are “Block” elements.
Ex: <div>, <p>, <h1>-<h6>, form etc.
Some elements take only the required space and don't start on a new line. These are “Inline” elements.
Ex: <a>, <span>, <br>, <strong>, <img> etc.
You will need to differentiate block elements from inline when you will be using CSS styles. In this HTML guide, it is not very necessary.
<title>My first web page</title>
<h2>This is a H2 heading. It has Block display.</h2>
<h2>This is <u>another</u> H2 heading. Here the underline tag has Inline display.</h2>
5. Double quote vs single quote in HTML
This question is very obvious. What should you use in HTML? Single quote or double quote? People seem to use both but which one is correct?
In HTML, single quote and double quote are same. They don't make any difference in the output.
You can use anyone you prefer. But mixing up both in a page of codes is considered a bad practice. You should be consistent with any one of them.
6. Semantic HTML vs Non-semantic HTML
Semantic HTML is the latest version of HTML, which is also called HTML5. It is the developed version of non-semantic HTML and XHTML.
Why is HTML5 better? In previous versions, HTML elements were identified by id/class names. For example: <div id=”article”> </div> was considered an article.
In HTML5, <article> </article> tag represents itself as an article without needing any id/class identifier.
For the sake of HTML5, now search engines and other web applications can better understand a web page. Semantic websites have proven to do better for SEO.
Here is a list of some popular HTML5 tags:
<main> </main> = This is for wrapping the main content that you want to show your viewers.
<header> </header> = This is for marking up the header part of a content such as title or author meta.
<article> </article> = It specifies a user-defined or independent content to your viewers.
<section> </section> = It can group any code such as header, footer or sidebar. You can say, it is the semantic form of a div.
<footer> </footer> = This is where your footer content, disclaimer or copyright text belong.
<audio> </audio> = It enables you insert audio files without having any plugin problem.
<video> </video> = Like <audio>, you can insert videos using this tag without plugin problems.
A simple HTML5 structure would look like this:
<meta charset="utf-8" />
<title>My first web page</title>
<h2>This is the title of the article</h2>
<p>Posted by John Doe</p>
<p>Content of the article goes here</p>
<p>Copyright 2017 John Doe</p>
7. HTML Validation
Most of the web professionals validate their code after finishing it. Why is it necessary to validate a code when it is working fine?
There are two possible reasons for validating your codes:
It will help you make your code cross-browser and cross-platform compatible. The code may not show any error in your current browser, but it might in another one. Code validation will fix it up.
Search engines and other web programs may stop crawling your page if you have errors in it. You can confirm through validation that you don't have any major error.
W3C Validator is the most popular service for code validation. They have several methods for validating codes. You can either upload a file or directly input the code in their validation engine.
8. Other Helpful Resources
HTML is an ever-learning topic. More updated versions of HTML might come sooner. So you have to stay updated and keep practicing. Practice is what aces HTML.
Founder of WebHostingSecretRevealed.net (WHSR) - a hosting review trusted and used by 100,000's users. More than 15 years experience in web hosting, affiliate marketing, and SEO. Contributor to ProBlogger.net, Business.com, SocialMediaToday.com, and more.