Opening and Closing HTML tags

As already shown with the <b> BOLD tag, some tags can have a “start” and an “end”.

The tag is used normally for the “start” one and a “/” is added to the beginning of it for the end one. e.g. <b> and </b>.

MOST, but not all, HTML tags have an open and a close.

Here are some examples:

  • <html></html> – marks the start and end of the HTML file
  • <body></body> – marks the start and end of the main “body” of the HTML page … this is the content that is to be displayed (other sections can hold “hidden” content instead)
  • <p></p> – marks the start and end of a paragraph
  • <table></table> – marks the start and end of a table
  • <tr></tr> – marks the start and end of a table row
  • <b></b> – marks the start and end of bold text
  • <i></i> – marks the start and end of italic text

Some tags don’t have an end or the end one is optional:

<p> – doesn’t need an end </p> as the computer will (usually) figure out for itself where a paragraph ends. If you add a second <p> it will guess that the previous paragraph is ended. So, for example “<p>Paragraph 1</p><p>Paragraph 2</p>” and
“<p>Paragraph 1<p>Paragraph 2” will both produce the same result even though the first one is more CORRECT.
<br> – means start a new line as opposed to <p> that starts a whole new paragraph. Mostly this will result in less space between the first and second line that you would get with a whole new paragraph. Sometimes it is written “</br>” instead. It doesn’t have a “start” and “end” so it doesn’t matter, you can use either.

There are not many others! Almost all HTML tags have an open and a close.