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
(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!
== HTML4 variations == Since its inception, HTML and its associated protocols gained acceptance relatively quickly. However, no clear standards existed in the early years of the language. Though its creators originally conceived of HTML as a semantic language devoid of presentation details,<ref>[https://www.w3.org/History/19921103-hypertext/hypertext/WWW/MarkUp/HTMLConstraints.html HTML Design Constraints], W3C Archives</ref> practical uses pushed many presentational elements and attributes into the language, driven largely by the various browser vendors. The latest standards surrounding HTML reflect efforts to overcome the sometimes chaotic development of the language<ref>[http://ei.cs.vt.edu/~wwwbtb/book/chap13/who.html WWW: BTB – HTML], Pris Sears</ref> and to create a rational foundation for building both meaningful and well-presented documents. To return HTML to its role as a semantic language, the [[World Wide Web Consortium|W3C]] has developed style languages such as [[Cascading Style Sheets|CSS]] and [[XSL]] to shoulder the burden of presentation. In conjunction, the HTML specification has slowly reined in the presentational elements. There are two axes differentiating various variations of HTML as currently specified: SGML-based HTML versus XML-based HTML (referred to as XHTML) on one axis, and strict versus transitional (loose) versus frameset on the other axis. === SGML-based versus XML-based HTML === One difference in the latest{{when|date=March 2022}} HTML specifications lies in the distinction between the SGML-based specification and the XML-based specification. The XML-based specification is usually called [[XHTML]] to distinguish it clearly from the more traditional definition. However, the root element name continues to be "html" even in the XHTML-specified HTML. The W3C intended XHTML 1.0 to be identical to HTML 4.01 except where limitations of XML over the more complex SGML require workarounds. Because XHTML and HTML are closely related, they are sometimes documented in parallel. In such circumstances, some authors [[(X)HTML|conflate the two names]] as (X)HTML or X(HTML). Like HTML 4.01, XHTML 1.0 has three sub-specifications: strict, transitional, and frameset. Aside from the different opening declarations for a document, the differences between an HTML 4.01 and XHTML 1.0 document—in each of the corresponding DTDs—are largely syntactic. The underlying syntax of HTML allows many shortcuts that XHTML does not, such as elements with optional opening or closing tags, and even empty elements which must not have an end tag. By contrast, XHTML requires all elements to have an opening tag and a closing tag. XHTML, however, also introduces a new shortcut: an XHTML tag may be opened and closed within the same tag, by including a slash before the end of the tag like this: {{code|lang=html|code=<br/>}}. The introduction of this shorthand, which is not used in the SGML declaration for HTML 4.01, may confuse earlier software unfamiliar with this new convention. A fix for this is remove the slash preceding the closing angle bracket, as such: {{code|lang=html|code=<br>}}.<ref>{{citation|title=HTML Standard - The br Element|url=https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-br-element|publisher=WHATWG}}</ref> To understand the subtle differences between HTML and XHTML, consider the transformation of a valid and well-formed XHTML 1.0 document that adheres to Appendix C (see below) into a valid HTML 4.01 document. Making this translation requires the following steps: # '''The language for an element should be specified with a <code>lang</code> attribute rather than the XHTML <code>xml:lang</code> attribute.''' XHTML uses XML's built-in language-defining functionality attribute. # '''Remove the XML namespace (<code>xmlns=URI</code>).''' HTML has no facilities for namespaces. # '''Change the document type declaration''' from XHTML 1.0 to HTML 4.01. (see [[#Document type declaration|DTD section]] for further explanation). # If present, '''remove the XML declaration.''' (Typically this is: {{code|lang=xml|code=<?xml version="1.0" encoding="utf-8"?>}}). # '''Ensure that the document's MIME type is set to <code>text/html</code>.''' For both HTML and XHTML, this comes from the HTTP <code>Content-Type</code> header sent by the server. # '''Change the XML empty-element syntax to an HTML style empty element''' ({{code|lang=html|code=<br/>}} to {{code|lang=html|code=<br>}}). Those are the main changes necessary to translate a document from XHTML 1.0 to HTML 4.01. To translate from HTML to XHTML would also require the addition of any omitted opening or closing tags. Whether coding in HTML or XHTML it may just be best to always include the optional tags within an HTML document rather than remembering which tags can be omitted. A well-formed XHTML document adheres to all the syntax requirements of XML. A valid document adheres to the content specification for XHTML, which describes the document structure. The W3C recommends several conventions to ensure an easy migration between HTML and XHTML (see [https://www.w3.org/TR/xhtml1/#guidelines HTML Compatibility Guidelines]). The following steps can be applied to XHTML 1.0 documents only: * Include both <code>xml:lang</code> and <code>lang</code> attributes on any elements assigning language. * Use the empty-element syntax only for elements specified as empty in HTML. * Remove the closing slash in empty-element tags: for example {{code|lang=html|code=<br>}} instead of {{code|lang=html|code=<br/>}}. * Include explicit close tags for elements that permit content but are left empty (for example, {{code|lang=html|code=}}, not {{code|lang=html|code=<div />}}). * Omit the XML declaration. By carefully following the W3C's compatibility guidelines, a user agent should be able to interpret the document equally as HTML or XHTML. For documents that are XHTML 1.0 and have been made compatible in this way, the W3C permits them to be served either as HTML (with a <code>text/html</code> [[MIME type]]), or as XHTML (with an <code>application/xhtml+xml</code> or <code>application/xml</code> MIME type). When delivered as XHTML, browsers should use an XML parser, which adheres strictly to the XML specifications for parsing the document's contents. === Transitional versus strict === HTML 4 defined three different versions of the language: Strict, Transitional (once called Loose), and Frameset. The Strict version is intended for new documents and is considered best practice, while the Transitional and Frameset versions were developed to make it easier to transition documents that conformed to older HTML specifications or did not conform to any specification to a version of HTML 4. The Transitional and Frameset versions allow for presentational markup, which is omitted in the Strict version. Instead, [[cascading style sheets]] are encouraged to improve the presentation of HTML documents. Because XHTML 1 only defines an XML syntax for the language defined by HTML 4, the same differences apply to XHTML 1 as well. The Transitional version allows the following parts of the vocabulary, which are not included in the Strict version: * '''A looser content model''' ** Inline elements and plain text are allowed directly in: <code>body</code>, <code>blockquote</code>, <code>form</code>, <code>noscript</code> and <code>noframes</code> * '''Presentation related elements''' ** underline (<code>u</code>) (Deprecated. can confuse a visitor with a hyperlink.) ** strike-through (<code>s</code>) ** <code>center</code> (Deprecated. use CSS instead.) ** <code>font</code> (Deprecated. use CSS instead.) ** <code>basefont</code> (Deprecated. use CSS instead.) * '''Presentation related attributes''' ** <code>background</code> (Deprecated. use CSS instead.) and <code>bgcolor</code> (Deprecated. use CSS instead.) attributes for <code>body</code> (required element according to the W3C.) element. ** <code>align</code> (Deprecated. use CSS instead.) attribute on <code>div</code>, <code>form</code>, paragraph (<code>p</code>) and heading (<code>h1</code>...<code>h6</code>) elements ** <code>align</code> (Deprecated. use CSS instead.), <code>noshade</code> (Deprecated. use CSS instead.), <code>size</code> (Deprecated. use CSS instead.) and <code>width</code> (Deprecated. use CSS instead.) attributes on <code>hr</code> element ** <code>align</code> (Deprecated. use CSS instead.), <code>border</code>, <code>vspace</code> and <code>hspace</code> attributes on <code>img</code> and <code>object</code> (caution: the <code>object</code> element is only supported in Internet Explorer (from the major browsers)) elements ** <code>align</code> (Deprecated. use CSS instead.) attribute on <code>legend</code> and <code>caption</code> elements ** <code>align</code> (Deprecated. use CSS instead.) and <code>bgcolor</code> (Deprecated. use CSS instead.) on <code>table</code> element ** <code>nowrap</code> (Obsolete), <code>bgcolor</code> (Deprecated. use CSS instead.), <code>width</code>, <code>height</code> on <code>td</code> and <code>th</code> elements ** <code>bgcolor</code> (Deprecated. use CSS instead.) attribute on <code>tr</code> element ** <code>clear</code> (Obsolete) attribute on <code>br</code> element ** <code>compact</code> attribute on <code>dl</code>, <code>dir</code> and <code>menu</code> elements ** <code>type</code> (Deprecated. use CSS instead.), <code>compact</code> (Deprecated. use CSS instead.) and <code>start</code> (Deprecated. use CSS instead.) attributes on <code>ol</code> and <code>ul</code> elements ** <code>type</code> and <code>value</code> attributes on <code>li</code> element ** <code>width</code> attribute on <code>pre</code> element * '''Additional elements in Transitional specification''' ** <code>menu</code> (Deprecated. use CSS instead.) list (no substitute, though the unordered list, is recommended) ** <code>dir</code> (Deprecated. use CSS instead.) list (no substitute, though the unordered list is recommended) ** <code>isindex</code> (Deprecated.) (element requires server-side support and is typically added to documents server-side, <code>form</code> and <code>input</code> elements can be used as a substitute) ** <code>applet</code> (Deprecated. use the <code>object</code> element instead.) * '''The <code>language</code> (Obsolete) attribute on script element''' (redundant with the <code>type</code> attribute). * '''Frame related entities''' ** <code>iframe</code> ** <code>noframes</code> ** <code>target</code> (Deprecated in the <code>map</code>, <code>link</code> and <code>form</code> elements.) attribute on <code>a</code>, client-side image-map (<code>map</code>), <code>link</code>, <code>form</code> and <code>base</code> elements The Frameset version includes everything in the Transitional version, as well as the <code>frameset</code> element (used instead of <code>body</code>) and the <code>frame</code> element. === Frameset versus transitional === In addition to the above transitional differences, the frameset specifications (whether XHTML 1.0 or HTML 4.01) specify a different content model, with <code>frameset</code> replacing <code>body</code>, that contains either <code>frame</code> elements, or optionally <code>noframes</code> with a <code>body</code>. === Summary of specification versions === As this list demonstrates, the loose versions of the specification are maintained for legacy support. However, contrary to popular misconceptions, the move to XHTML does not imply a removal of this legacy support. Rather the X in XML stands for extensible and the W3C is modularizing the entire specification and opens it up to independent extensions. The primary achievement in the move from XHTML 1.0 to XHTML 1.1 is the modularization of the entire specification. The strict version of HTML is deployed in XHTML 1.1 through a set of modular extensions to the base XHTML 1.1 specification. Likewise, someone looking for the loose (transitional) or frameset specifications will find similar extended XHTML 1.1 support (much of it is contained in the legacy or frame modules). Modularization also allows for separate features to develop on their own timetable. So for example, XHTML 1.1 will allow quicker migration to emerging XML standards such as [[MathML]] (a presentational and semantic math language based on XML) and [[XForms]]—a new highly advanced web-form technology to replace the existing HTML forms. In summary, the HTML 4 specification primarily reined in all the various HTML implementations into a single clearly written specification based on SGML. XHTML 1.0, ported this specification, as is, to the new XML-defined specification. Next, XHTML 1.1 takes advantage of the extensible nature of XML and modularizes the whole specification. XHTML 2.0 was intended to be the first step in adding new features to the specification in a standards-body-based approach.
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)