ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Learning HTML For Beginners

Updated on April 19, 2016

Step 1: Get a source code editor

This tutorial is going to take you through the process of using HTML to create a website. First you want to begin by using a source code editor like Sublime Text 3 or Notepad ++ to write your code in.

I personally like to use Sublime Text 3. Here is a link to the page where you can download it:

Step 2: Set up your index file

Create a new folder on your desktop and save it as new_website. Open your code editor and create a new file, save your new file as index.html in your new_website folder. By saving as index.html you are creating a default page that the web server will recognize as the top level page to open.

*Quick Tip* Once you save the file as html, you can simply type html and Tab and the file setup will automatically complete.

If you are not using Sublime Text 3 you can type this code manually.

This is what you should see:

HTML Auto Complete


Step 3: Using tags

As you can see the content is contained using tags. There must be an opening tag and a closing tag in order for it to work properly. A closing tag looks like this />, it is just a back slash and closing bracket. There are some special tags that are self containing and don't require a closing tag such as the line break tag <br>. The <br> tag creates a new line of text beneath the existing line of text.

The placement of the tags on the page are very important as they perform in a hierarchy sequence. For example the most important tag is first, the <!DOCTYPE html> tag is telling the browser what kind of document it is defined as, in this case it is an html file. The <!DOCTYPE html> is followed by an opening and closing html tag which contains all of the content for the page.

The next tag which is processed by the browser is the head tag which has the information that is placed in the head of the document. Here you will find the title tag, script tag, link tag, meta tag and a few others.

Thar part of the document where you want to place your content is in the body. In the video example I have provided, you will see that I started with the heading tags. The heading tags come in different default sizes however these can be customized and styled to your liking. It is general practice to style a page using the largest heading <h1> to the smallest heading <h5> as you place headings into your document.

Video Tutorial HTML For Beginners

Step 4: Using proper syntax

You want to make sure that the html is written properly in lower case letters. The <!DOCTYPE html> tag however is always written in upper case letters. It is very important to nest your elements properly so that your parent tag contains the content and closes after the content. In the image below you will notice that the section tag is containing the <ul> tag and the list elements are contained within the <ul> tag.

HTML Syntax

Step 5: Using Classes

One of the ways to target a specific section of code is by giving it a class. A class can give the code a certain type of style which is targeted in the css. To write a class for a section of code you begin with the div tag. You then need to give a name to your class, it is best to name it something that will make sense. For example if you want to contain a section within a purple box you can type <div class="purplebox"></div>. The closing div tag would be placed at the very end of the paragraph or where you would like to close the section. By calling the class something specific you will make it easier to understand your own code when you want to edit.

Once your class is applied in your index file, you will then have to create a css file or open a style tag in the head of the document to style your class. A class is called in the stylesheet with a . in front of it. For example our purple box class will be written as .purplebox{}. It must have opening and closing curly brackets. The styles that you would like to apply to the class are contained within the curly brackets followed by a semi colon;

You can apply classes to html elements like the p tag, img tag, heading tags etc. When you give a class to the p tag it will only affect the text of that section. The same applies with heading tags.

Using an id selector

Another way to select a portion of code that you would like to style is by containing it with an id selector. The id selector can be applied using a div tag and is used in the same way that a class is used with the exception that the id name cannot be used more than once. It must have a unique name to target a specific element.

Another difference between the classes and id's is that id's are targeted in css with a # hashtag rather than a period. Just like with classes, you want to give an id a name that is suitable for what it's being used for.

The styles in the browser

Adding margins and padding

As you can see, the text inside of the box is squished to the very edge of the box. If you would like for the text to have some more space in between so that it looks nicer you will have to give it padding. Padding is space that is applied either to the top, right, bottom or left of the element.

For the purple box I will apply 20px of padding to all of the sides by simply coding it as padding: 20px; This targets all of the sides of the box. You also have the option to target only certain sides, for example you can say padding-top:20px; and it will only affect the top portion between the text and the box.

Adding padding and margin

The padding and margin in the browser

Spacing your elements

When you want to add padding to a p tag, you want to target the p in the css because by adding padding to the box, the box will become larger. If you would like to add margin to the box simply apply the margin to box class. As you can see the difference between the first box that didn't have padding versus after the padding styles were applied, it looks much nicer and appealing for the user.

If you would like to center align the boxes you can apply margin: auto 0 to the box class.

Follow the links below for more information

Thanks for checking out my tutorial for beginner HTML, if you would like some more information make sure to check out the following links to help you out with your coding.

Code on!


    0 of 8192 characters used
    Post Comment

    No comments yet.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)