Are there tags that have no special purpose?

1

I often come across HTML tags being used in two ways.

First form:

<title>Stackoverflow</title>

Second form:

<meta charset="utf-8">

Notice that in the tag title there was the closing </> and in tag meta there was no closing.

In situations where there are tags that has a closing and others that do not have a closing I have the following doubt.

Doubt

Does tags have no special purpose? Are they just tags that set up something on the page? Like the tag meta that defines the encoding.

    
asked by anonymous 31.03.2017 / 00:59

1 answer

3

No, they are just tags that do not need to be closed, meaning they do not have content that they control. Po can be a <meta> or it can be a <br> . The tag exists by itself. It may have attributes, as demonstrated in the question. A <img> has on the properties all that it needs, the closing would only be necessary to indicate that the content has ended, but not any content bound to tag other than itself.

Most simple tags rendered something even though they did not have associated content. The content can be determined in an attribute, in the case of <img> where it is already the image itself or <br> that only renders a "skip line".

I have already mentioned two cases that are not for nothing configuration. Other:

  • area
  • base
  • col
  • command
  • embed
  • hr
  • input
  • keygen
  • link
  • menuitem
  • param
  • source
  • track
  • wbr

Have I forgotten any of these?

tags that have terminators need tr associated content, which can be a text or a tag or a set of tags . Having closure is something that is only necessary when there is something that needs to be determined that has finished what needs to be described. Think of ; and { } in most programming languages. Why is there something that only indicates the end and something that indicates beginning and end? It is the same motif, one element indicates something unique and another indicates something composed, which needs an indicator that the composition has ended. The same could be said of the quotation marks. Why do not you need a terminator in a number or a true ? Because there is a rule that identifies its composition, unlike string that needs something that determines its beginning and end. it is only because of this that there is the terminator or lack thereof.

Why do this?

<meta charset="utf-8"></meta>

If this is enough?

<meta charset="utf-8">

Related: The right one is

31.03.2017 / 01:12