-1

In void element such as <img> where is the opening and closing tag exactly? I understand that the we only use one tag since there is no text content to be written for this element to be shown in the browser, instead an embedded image would show. Does this mean that <img>counts as an opening tag and closing tag, so it counts as both types of tags? I thought to clear this concept up since could not find a similar question asked before on this site.

parsakam
  • 3
  • 1
  • Welcome to Stack Overflow! Please visit [help], take [tour] to see what and [ask]. ***[Do some research](https://www.google.com/search?q=html5+void+elements+site:stackoverflow.com)***, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output, preferably in a [Stacksnippet](https://blog.stackoverflow.com/2014/09/introducing-runnable-javascript-css-and-html-code-snippets/) – mplungjan Dec 30 '20 at 07:49
  • From the dupe: `The "/" is completely optional on the above tags, however, so is not different from , but is invalid.` – mplungjan Dec 30 '20 at 07:50
  • Hi! Can you please help us understand the context of this question? are you trying to solve something (like a tool that used tart and close tags), or just curious? Because it looks like more of a semantic question (and the answer can be "they don't have closing tags" or "they're both opening and closing tags"). – Kobi Dec 30 '20 at 07:52

1 Answers1

0

Void elements have start tags. They do not have end tags.

The start tag doesn’t count as an end tag. It is simply the only tag used to represent the element.

Take the img element in the specification where it says:

Tag omission in text/html:
No end tag.

Quentin
  • 800,325
  • 104
  • 1,079
  • 1,205