Skip to content

HTML for greens - HTML

Tags

What are HTML tags?

Aside from regular text on a page, you can introduce tags (also known as markup). A tag is a special text enclosed in angle brackets, for example: <b>. It is part of the HTML language syntax and allows you to control the appearance of the page. Thanks to it, you can, for example, set the background color, apply text formatting, insert an image or a table, and so on. The tag is not visible on the screen. Only the effects of its operation are visible (e.g., inserting an image). To make the <b> tag above visible, I had to use a little "trick" (if you can't wait and want to know what it is right now, take a look at the page: Special Characters).

Because the characters: "<" (less-than sign) and ">" (greater-than sign) are reserved for tags, they should not appear in normal page content. If you need to use them, you should enter them as: &lt; and &gt; respectively. Additionally, the "&" (ampersand) should be replaced with: &amp;

There are opening tags (e.g., <b>) and closing tags (e.g., </b>). Notice that the closing tag begins with a slash (the "/" character) and has the same name as the opening tag. Between the opening and closing tags, you can place some text that you want to format (in this case, it will be text in bold), for example:

<b>This text will be bold.</b>
or
<b>
This text will be bold.
</b>
(both of the above methods are equivalent).

The opening tag must always appear before the closing tag. This is quite a logical rule, as you can't close doors that haven't been opened yet, and you can't open doors that aren't closed... unless we're talking about revolving doors 😉 It's also important to remember that almost every tag (with a few exceptions) must be closed with the appropriate closing tag, which means you can't forget to insert closing tags!

In HTML, it doesn't matter what letters we use for tags; for example, the <html> tag can be written like this: <hTmL>. However, you'll agree that the second way is not very readable. That's why in this course, all tags will be written in lowercase.

Practically every HTML editor offers:

  • Syntax highlighting, which means that if you enter a valid tag, its syntax will be displayed in a specific color, depending on the program's settings. This immediately highlights all errors, typically simple typos. This is probably the most important advantage of using HTML editors. This is why it is not recommended to use regular text editors for creating web pages.
  • Automatic closing of tags, which involves the program automatically adding the appropriate closing tag right after the user provides the opening tag. This speeds up work significantly, and you won't forget to close tags because the program does it for you automatically.
  • Generators (or wizards) help with creating various tags (through special dialog boxes).

Questions and Answers

What are tags?

A tag is a special text enclosed in angle brackets. It is a part of the HTML language syntax and allows you to control the appearance of a webpage. There are opening and closing tags. At the beginning of a closing tag, there is always a forward slash character "/".

What are tags used for?

HTML tags are used for formatting text and inserting additional elements on a webpage.

How to insert special characters in HTML?

Because the characters: "<" (less than sign) and ">" (greater than sign) are reserved for tags, they should not appear in the normal content of a webpage. If you need to use them, you should enter them as follows: &lt; and &gt;.