Open post ↗

HTML for beginners

Properties

typeNote
date22 July 2021
seriesDev basics
tagsprogramminghtmlbeginners-guidecodingweb-development

HTML stands for Hyper Text Markup Language. It is used to create the structure of our web pages. In earlier years it was used to make documents that were displayed as web pages. Its purpose still hasn’t changed but now it’s much more than just creating documents. It is one of the 3 major languages used in Web development.

Those three languages are:

  1. HTML
  2. CSS
  3. JavaScript

All of them have different purposes and features that are combined to make a single website. Think of a Website as a Human Body, the HTML would be its skeleton, CSS would be its outer features and JavaScript would be all the internal functionality!

HTML Elements

HTML elements are basic blocks of a web document. Different Elements have different properties and when combined with other elements can produce changed results.

In this section we will learn about HTML basics. The Elements we will cover are:

Basic HTML boilerplate: This is a basic HTML document.

<!-- This is a basic html structure -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
</body>
</html>
  • <!DOCTYPE html> means that the document type is HTML. After that is the html tag with the lang attribute in it, showing that the language is English.
  • The <head> tag is used to give information about the web page. It contains many meta elements showing which character set to use and what the content width should be.
  • The <title> tag is used to show the title of the page (usually the one written on the opened tab button).
  • </> indicates the closing of a tag.
  • <body> represents the body of the web page.

Text (displaying text on a web page):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>This is a web page</p>
    <h1>This is a html document</h1>
    <h3>This is a beginners guide </h3>
</body>
</html>

In the <body> tag you can see different elements used, such as <p> representing a paragraph and <h1> representing a heading, with 1 being the biggest font and 6 being the smallest. Although keep in mind that it’s not a matter of size (size can always be changed using CSS), headings are used according to the importance of the content. It is preferred that we use only one <h1> heading so that search engines can easily figure out what the content is about!

Note: If you are an extreme beginner and are not sure how to output the result, all you have to do is to open the HTML document using your web browser.

Entities: Some characters are reserved in HTML, so in order to display them we have to use a special notation. Suppose we wanted to display “I love <html>” on the web page. When we write it in a <p> tag the editor confuses it with the <html> element which is another tag. So to solve this problem we use HTML entities.

  • &lt;: the & sign is used, and lt stands for less than.
  • &gt; means greater than.

There are many other entities we can use. You can look them up if you want to, but we rarely use them.

Hyperlinks: Almost all the web pages on the internet include links to other pages. To add these links to our web page we use the anchor element or the <a href=”” >. Every anchor element should have a href or hyper text reference attribute.

</head>
<body>
    <a href="https://www.google.com" target="_blank">Google</a>
</body>
</html>

What this code does is it creates a word named Google, and when you click on it, the Google search page is opened. The target="_blank" attribute means the page will open in a new tab. If we don’t use this attribute, the page will open in the current tab.

We can use this element to create a link between different pages of our website, i.e. home page, about page …

Embedding Images: The <img> element is used to add or link images to our website. It includes a src or source attribute and an alt or alternative (text to be displayed in case the image is not available).

</head>
<body>
    <img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Google logo">
</body>
</html>