Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between "> or " /> in HTML

Tags:

html

tags

Is there any difference between <...> and <.../>

Very straight forward:

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

Is there any difference in execution, functions etc.?

like image 421
Mathias Asberg Avatar asked Apr 23 '13 15:04

Mathias Asberg


People also ask

What's the difference between BR and br />?

In practice, </br> does not exist. Just <br> or <br /> . However, the difference is the position, and is universal for all XML tags. <TAG_NAME> indicates the beginning of a tag, and </TAG_NAME> indicates the end of a tag.

What is the difference between an opening and closing HTML tag?

An opening tag begins a section of page content, and a closing tag ends it. For example, to markup a section of text as a paragraph, you would open the paragraph with an opening paragraph tag <p> and close it with a closing paragraph tag </p> (closing tags always proceed the element with a /).

How can I tell the difference between HTML files?

Difference Between HTML and HTML5HTML uses browser cache memory as temporary storage. HTML5 offers multiple storage options, such as an SQL database, application cache, and web storage. Programmers are unable to use features that determine a user's geolocation..


2 Answers

XHTML requires trailing slashes for elements like ("br", "input", "img") whereas in HTML5 they're optional.

See: Should I remove trailing slashes in meta tags?

See also: Does HTML 5 Use a Trailing Slash

like image 162
jball037 Avatar answered Sep 30 '22 02:09

jball037


Tags that do not have closing tags in HTML (like <br> and <meta>) are called self-closing. <br> and <br /> are equally valid in HTML.

However, XML does not permit closing tags to be omitted; <head><meta></head> is invalid XML! The / prior to the > character indicates to XML that this tag should be immediately closed. That is, <x></x> is semantically equivalent to <x /> in XML.

You should prefer the form <br /> when writing HTML code that you want to also be valid XHTML. If you do not care about XML or XHTML, you can pick which syntax you prefer.


Note that <br/> is valid XML with the same meaning as <br />, but older browsers with parsing bugs would parse that tag as a tag with the name br/. Adding a space in between the tag name and the / chararcter satisfies the parsers of defective browsers (who then treat the / as an attribute name), while still producing well-formed XML.

like image 43
cdhowie Avatar answered Sep 30 '22 01:09

cdhowie