Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
HTML element
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Elements vs. tags=== As is generally understood, the position of an element is indicated as spanning from a start tag and is terminated by an end tag.<ref name="HTML401_Elements">{{Cite web |at=§3.2.1 Elements |title=§3 On SGML and HTML |work=HTML 4.01 Specification |date=24 December 1999 |url=http://www.w3.org/TR/1999/REC-html401-19991224/intro/sgmltut.html#h-3.2.1 |publisher=[[W3C]] }}</ref> This is the case for many, but not all, elements within an HTML document. The distinction is explicitly emphasised in ''HTML 4.01 Specification'': {{quote|'''Elements are not tags.''' Some people refer to elements as tags (e.g., "the P tag"). Remember that the element is one thing, and the tag (be it start or end tag) is another. For instance, the HEAD element is always present, even though both start and end HEAD tags may be missing in the markup.<ref name="HTML401_Elements"/>}} Similarly the W3C Recommendation '''''HTML 5.1 2nd Edition''''' explicitly says: {{quote| source=[https://www.w3.org/TR/html51/syntax.html#tags HTML 5.1 2nd Edition § 8.1.2. Elements § Tags] | '''Tags''' are used to delimit the start and end of elements in the markup. (...) The start and end tags of certain normal elements can be omitted, (...) <br/> The contents of the element must be placed between just after the start tag (which <u>might be implied</u>, in certain cases) and just before the end tag (which again, <u>might be implied</u>, in certain cases). }} and: {{quote| source=[https://www.w3.org/TR/html51/syntax.html#optional-tags HTML 5.1 2nd Edition § 8.1.2.4. Optional tags] | Certain tags can be '''omitted'''. <br/> '''NOTE:'''<br/> Omitting an element's start tag (...) does not mean the element is not present; it is implied, but it is still there. For example, an HTML document always has a root <kbd><nowiki><html></nowiki></kbd> element, even if the string <kbd><nowiki><html></nowiki></kbd> doesn't appear anywhere in the markup. }} As HTML (before HTML5) is based on [[SGML]],<ref>{{Cite web |at=§3.1 Introduction to SGML |title=§3 On SGML and HTML |work=HTML 4.01 Specification |date=24 December 1999 |url=http://www.w3.org/TR/1999/REC-html401-19991224/intro/sgmltut.html |publisher=[[W3C]] }}</ref> its parsing also depends on the [[Document Type Definition|Document Type Definition (DTD)]], specifically an HTML DTD (e.g. HTML 4.01<ref name="W3C, HTML 401 DTD" >{{Cite web |title=HTML 4.01, §21, Document Type Definition |date=24 December 1999 |url=http://www.w3.org/TR/1999/REC-html401-19991224/sgml/dtd.html |publisher=[[W3C]] }}</ref>{{refn|group=note|HTML 4.01 is one of a small number of well-known HTML DTDs. It is chosen here as the best illustrative example, although the same behavior applies to the other W3C-published DTDs for HTML.}}). The DTD specifies which element types are possible (i.e. it defines the set of element types) and also the valid combinations in which they may appear in a document. It is part of general SGML behavior that, where only one valid structure is {{em|possible}} (per the DTD), its explicit statement in any given document is not generally required. As a simple example, the {{code|lang=html|code=<p>}} tag indicating the start of a paragraph element should be complemented by a {{code|lang=html|code=</p>}} tag indicating its end. But since the DTD states that paragraph elements cannot be nested, an HTML document fragment {{code|lang=html|code=<p>Para 1 <p>Para 2 <p>Para 3 }} is thus inferred to be equivalent to {{code|lang=html|code=<p>Para 1 </p><p>Para 2 </p><p>Para 3 }}. (If one paragraph element cannot contain another, any currently open paragraph must be closed before starting another.) Because this implication is based on the combination of the DTD and the individual document, it is not usually possible to infer elements from document tags {{em|alone}} but only by using an SGML—or HTML—aware parser with knowledge of the DTD. [[HTML5]] creates a similar result by defining what tags can be omitted.<ref name=whatwg-syntax-tag-omission>{{cite web |title=HTML Standard § Optional tags |url=https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission |website=WHATWG |access-date=22 March 2019}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)