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!
==== Types of element ==== There are three kinds of [[HTML]] elements: normal elements, raw text elements, and void elements. '''{{vanchor|Normal elements}}''' usually have both a start tag and an end tag, although for some elements the end tag, or both tags, can be omitted. It is constructed in a similar way: * a ''start tag'' ({{tag|{{var|tag}}|o}}) marking the beginning of an element, which may incorporate any number of [[HTML attribute]]s; * some amount of ''content'', including text and other elements; * an ''end tag'', in which the element name is prefixed with a [[Slash (punctuation)|slash]]: {{tag|{{var|tag}}|c}}. '''{{vanchor|Raw text elements}}''' (also known as text or text-only elements) are constructed with: * a ''start tag'' (in the form {{tag|{{var|tag}}|o}}) marking the beginning of an element, which may incorporate any number of HTML attributes; * some amount of text ''content'', but no elements (all tags, apart from the applicable end tag, will be interpreted as content); * an ''end tag'', in which the element name is prefixed with a slash: {{tag|{{var|tag}}|c}}. In some versions of HTML, the end tag is optional for some elements. The end tag is required in [[XHTML]]. An example is the {{tag|title|o}} element, which must not contain other elements (including markup of text), only {{em|plain}} text. '''{{Anchor|Empty element}}{{vanchor|Void elements}}''' (also sometimes called empty elements, single elements or stand-alone elements) only have a start tag (in the form {{tag|{{var|tag}}|o}}), which contains any HTML attributes. They may not contain any children, such as text or other elements. For compatibility with [[XHTML]], the HTML specification{{Which|date=August 2022}} allows an optional space and slash{{Citation needed|date=August 2022}} ({{tag|{{var|tag}}|s}} is permissible). The slash is required in [[XHTML]] and other [[XML]] applications. Two common void elements are {{tag|br|s}} (for a [[Hard return|hard line-break]], such as in a poem or an address) and {{tag|hr|s}} (for a thematic break). Other such elements are often place-holders which reference external files, such as the image ({{tag|img|s}}) element. The attributes included in the element will then point to the external file in question. Another example of a void element is {{tag|link|s}}, for which the syntax is: <syntaxhighlight lang="html"> <link rel="stylesheet" href="fancy.css" type="text/css"> </syntaxhighlight> This {{tag|link|s}} element points the browser at a [[Style sheet (web development)|style sheet]] to use when presenting the HTML document to the user. In the HTML syntax attributes do not have to be quoted if they are composed only of certain characters: letters, digits, the hyphen-minus and the period. When using the XML syntax (XHTML), on the other hand, all attributes must be quoted, and a spaced trailing [[Slash (punctuation)|slash]] is required before the last angle bracket: <syntaxhighlight lang="xml"> <link rel="stylesheet" href="fancy.css" type="text/css" /> </syntaxhighlight>
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)