Misplaced Pages

Character encodings in HTML

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
#812187

52-458: While Hypertext Markup Language ( HTML ) has been in use since 1991, HTML 4.0 from December 1997 was the first standardized version where international characters were given reasonably complete treatment. When an HTML document includes special characters outside the range of seven-bit ASCII , two goals are worth considering: the information's integrity , and universal browser display. There are two general ways to specify which character encoding

104-500: A Document type declaration (informally, a "doctype"). In browsers, the doctype helps to define the rendering mode—particularly whether to use quirks mode . The original purpose of the doctype was to enable the parsing and validation of HTML documents by SGML tools based on the Document type definition (DTD). The DTD to which the DOCTYPE refers contains a machine-readable grammar specifying

156-431: A byte-oriented ASCII superset encoding, and they are less efficient for text with a high frequency of ASCII characters, which is usually the case for HTML documents. Successful viewing of a page is not necessarily an indication that its encoding is specified correctly. If the page's creator and reader are both assuming some platform-specific character encoding, and the server does not send any identifying information, then

208-486: A web browser . It defines the content and structure of web content . It is often assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript, a programming language. Web browsers receive HTML documents from a web server or from local storage and render the documents into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for its appearance. HTML elements are

260-649: A character by its Universal Character Set / Unicode code point , and uses the format or where nnnn is the code point in decimal form, and hhhh is the code point in hexadecimal form. The x must be lowercase in XML documents. The nnnn or hhhh may be any number of digits and may include leading zeros. The hhhh may mix uppercase and lowercase, though uppercase is the usual style. Not all web browsers or email clients used by receivers of HTML documents, or text editors used by authors of HTML documents, will be able to render all HTML characters. Most modern software

312-407: A contractor at CERN , proposed and prototyped ENQUIRE , a system for CERN researchers to use and share documents. In 1989, Berners-Lee wrote a memo proposing an Internet -based hypertext system. Berners-Lee specified HTML and wrote the browser and server software in late 1990. That year, Berners-Lee and CERN data systems engineer Robert Cailliau collaborated on a joint request for funding, but

364-430: A declaration can be included within the document itself. For HTML it is possible to include this information inside the head element near the top of the document: HTML5 also allows the following syntax to mean exactly the same: XHTML documents have a third option: to express the character encoding via XML declaration, as follows: With this second approach, because the character encoding cannot be known until

416-1013: A few special characters (or none at all if a native Unicode encoding like UTF-8 is used). Incorrect HTML entity escaping may also open up security vulnerabilities for injection attacks such as cross-site scripting . If HTML attributes are left unquoted, certain characters, most importantly whitespace , such as space and tab, must be escaped using entities. Other languages related to HTML have their own methods of escaping characters. Unlike traditional HTML with its large range of character entity references, in XML there are only five predefined character entity references. These are used to escape characters that are markup sensitive in certain contexts: All other character entity references have to be defined before they can be used. For example, use of é (which gives é, Latin lower-case E with acute accent, U+00E9 in Unicode) in an XML document will generate an error unless

468-437: A list of all named HTML character entity references along with the versions in which they were introduced, see List of XML and HTML character entity references . Unnecessary use of HTML character references may significantly reduce HTML readability. If the character encoding for a web page is chosen appropriately, then HTML character references are usually only required for markup delimiting characters as mentioned above, and for

520-447: A pair is the start tag , and the second is the end tag (they are also called opening tags and closing tags ). Another important component is the HTML document type declaration , which triggers standards mode rendering. The following is an example of the classic "Hello, World!" program : The text between < html > and </ html > describes the web page, and

572-721: A processor of HTML, such as a web browser, should be able to parse the declaration in some cases through the use of heuristics. As of HTML5 the recommended charset is UTF-8 . An "encoding sniffing algorithm" is defined in the specification to determine the character encoding of the document based on multiple sources of input, including: Characters outside of the printable ASCII range (32 to 126) usually appear incorrectly. This presents few problems for English -speaking users, but other languages regularly—in some cases, always—require characters outside that range. In Chinese, Japanese, and Korean ( CJK ) language environments where there are several different multi-byte encodings in use, auto-detection

SECTION 10

#1732858635813

624-425: A start tag) and do not use an end tag. Many tags, particularly the closing end tag for the very commonly used paragraph element < p > , are optional. An HTML browser or other agent can infer the closure for the end of an element from the context and the structural rules defined by the HTML standard. These rules are complex and not widely understood by most HTML authors. The general form of an HTML element

676-590: A user can give input/s like: Comments: Comments can help in the understanding of the markup and do not display in the webpage. There are several types of markup elements used in HTML: Most of the attributes of an element are name–value pairs , separated by = and written within the start tag of an element after the element's name. The value may be enclosed in single or double quotes, although values consisting of certain characters can be left unquoted in HTML (but not XHTML). Leaving attribute values unquoted

728-538: Is able to display most or all of the characters for the user's language, and will draw a box or other clear indicator for characters they cannot render. For codes from 0 to 127, the original 7-bit ASCII standard set, most of these characters can be used without a character reference. Codes from 160 to 255 can all be created using character entity names . Only a few higher-numbered codes can be created using entity names, but all can be created by decimal number character reference. Character entity references can also have

780-448: Is also often employed. Finally, browsers usually permit the user to override incorrect charset label manually as well. It is increasingly common for multilingual websites and websites in non-Western languages to use UTF-8 , which allows use of the same encoding for all languages. UTF-16 or UTF-32 , which can be used for all languages as well, are less widely used because they can be harder to handle in programming languages that assume

832-464: Is considered unsafe. In contrast with name-value pair attributes, there are some attributes that affect the element simply by their presence in the start tag of the element, like the ismap attribute for the img element. There are several common attributes that may appear in many elements : The abbreviation element, abbr , can be used to demonstrate some of these attributes: This example displays as HTML ; in most browsers, pointing

884-456: Is for HTML5. If a declaration is not included, various browsers will revert to " quirks mode " for rendering. HTML documents imply a structure of nested HTML elements . These are indicated in the document by HTML tags , enclosed in angle brackets thus: < p > . In the simple, general case, the extent of an element is indicated by a pair of tags: a "start tag" < p > and "end tag" </ p > . The text content of

936-401: Is therefore: < tag attribute1 = "value1" attribute2 = "value2" > ''content'' </ tag > . Some HTML elements are defined as empty elements and take the form < tag attribute1 = "value1" attribute2 = "value2" > . Empty elements may enclose no content, for instance, the < br /> tag or

988-552: Is used in the document. First, the web server can include the character encoding or " charset " in the Hypertext Transfer Protocol (HTTP) Content-Type header, which would typically look like this: This method gives the HTTP server a convenient way to alter document's encoding according to content negotiation ; certain HTTP server software can do it, for example Apache with the module mod_charset_lite . Second,

1040-570: The Internet Engineering Task Force (IETF) with the mid-1993 publication of the first proposal for an HTML specification, the "Hypertext Markup Language (HTML)" Internet Draft by Berners-Lee and Dan Connolly , which included an SGML Document type definition to define the syntax. The draft expired after six months, but was notable for its acknowledgment of the NCSA Mosaic browser's custom tag for embedding in-line images, reflecting

1092-434: The de facto web standard for some time. HTML markup consists of several key components, including those called tags (and their attributes ), character-based data types , character references and entity references . HTML tags most commonly come in pairs like < h1 > and </ h1 > , although some represent empty elements and so are unpaired, for example < img > . The first tag in such

SECTION 20

#1732858635813

1144-419: The replacement character (�), refusing to process it at all. This is intended to prevent attacks (e.g. cross site scripting ) which may exploit a difference between the client and server in what encodings are supported in order to mask malicious content. Although the same security concern applies to ISO-2022-JP and UTF-16 , which also allow sequences of ASCII bytes to be interpreted differently, this approach

1196-452: The IETF's philosophy of basing standards on successful prototypes. Similarly, Dave Raggett 's competing Internet Draft, "HTML+ (Hypertext Markup Format)", from late 1993, suggested standardizing already-implemented features like tables and fill-out forms. After the HTML and HTML+ drafts expired in early 1994, the IETF created an HTML Working Group. In 1995, this working group completed "HTML 2.0",

1248-540: The XML syntax for HTML and is no longer being developed as a separate standard. On 28 May 2019, the W3C announced that WHATWG would be the sole publisher of the HTML and DOM standards. The W3C and WHATWG had been publishing competing standards since 2012. While the W3C standard was identical to the WHATWG in 2007 the standards have since progressively diverged due to different design decisions. The WHATWG "Living Standard" had been

1300-473: The attribute value itself. If document authors overlook the need to escape such characters, some browsers can be very forgiving and try to use context to guess their intent. The result is still invalid markup, which makes the document less accessible to other browsers and to other user agents that may try to parse the document for search and indexing purposes for example. Escaping also allows for characters that are not easily typed, or that are not available in

1352-566: The browser, and these characteristics can be altered or enhanced by the web page designer's additional use of CSS . Many of the text elements are mentioned in the 1988 ISO technical report TR 9537 Techniques for using SGML , which describes the features of early text formatting languages such as that used by the RUNOFF command developed in the early 1960s for the CTSS (Compatible Time-Sharing System) operating system. These formatting commands were derived from

1404-486: The building blocks of HTML pages. With HTML constructs, images and other objects such as interactive forms may be embedded into the rendered page. HTML provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links , quotes, and other items. HTML elements are delineated by tags , written using angle brackets . Tags such as < img > and < input > directly introduce content into

1456-433: The characters < and & (when written as &lt; and &amp; , respectively) to be interpreted as character data, rather than markup. For example, a literal < normally indicates the start of a tag, and & normally indicates the start of a character entity reference or numeric character reference; writing it as &amp; or &#x26; or &#38; allows & to be included in

1508-441: The characters of the world's writing systems. HTML defines several data types for element content, such as script data and stylesheet data, and a plethora of types for attribute values, including IDs, names, URIs , numbers, units of length, languages, media descriptors, colors, character encodings, dates and times, and so on. All of these data types are specializations of character data. HTML documents are required to start with

1560-447: The commands used by typesetters to manually format documents. However, the SGML concept of generalized markup is based on elements (nested annotated ranges with attributes) rather than merely print effects, with separate structure and markup. HTML has been progressively moved in this direction with CSS. Berners-Lee considered HTML to be an application of SGML. It was formally defined as such by

1612-535: The content of an element or in the value of an attribute. The double-quote character ( " ), when not used to quote an attribute value, must also be escaped as &quot; or &#x22; or &#34; when it appears within the attribute value itself. Equivalently, the single-quote character ( ' ), when not used to quote an attribute value, must also be escaped as &#x27; or &#39; (or as &apos; in HTML5 or XHTML documents ) when it appears within

Character encodings in HTML - Misplaced Pages Continue

1664-664: The cursor at the abbreviation should display the title text "Hypertext Markup Language." Most elements take the language-related attribute dir to specify text direction, such as with "rtl" for right-to-left text in, for example, Arabic , Persian or Hebrew . As of version 4.0, HTML defines a set of 252 character entity references and a set of 1,114,050 numeric character references , both of which allow individual characters to be written via simple markup, rather than literally. A literal character and its markup counterpart are considered equivalent and are rendered identically. The ability to " escape " characters in this way allows for

1716-428: The declaration is parsed, there is a problem knowing which character encoding is used in the document up to and including the declaration itself. If the character encoding is an ASCII extension then the content up to and including the declaration itself should be pure ASCII and this will work correctly. For character encodings that are not ASCII extensions (i.e. not a superset of ASCII), such as UTF-16BE and UTF-16LE ,

1768-589: The document's character encoding , to be represented within the element and attribute content. For example, the acute-accented e ( é ), a character typically found only on Western European and South American keyboards, can be written in any HTML document as the entity reference &eacute; or as the numeric references &#xE9; or &#233; , using characters that are available on all keyboards and are supported in all character encodings. Unicode character encodings such as UTF-8 are compatible with all modern browsers and allow direct access to almost all

1820-445: The element, if any, is placed between these tags. Tags may also enclose further tag markup between the start and end, including a mixture of tags and text. This indicates further (nested) elements, as children of the parent element. The start tag may also include the element's attributes within the tag. These indicate other information, such as identifiers for sections within the document, identifiers used to bind style information to

1872-411: The entity has already been defined. XML also requires that the x in hexadecimal numeric references be in lowercase: for example &#xA1b rather than &#XA1b . XHTML , which is an XML application, supports the HTML entity set, along with XML's predefined entities. HTML Hypertext Markup Language ( HTML ) is the standard markup language for documents designed to be displayed in

1924-506: The first HTML specification intended to be treated as a standard against which future implementations should be based. Further development under the auspices of the IETF was stalled by competing interests. Since 1996, the HTML specifications have been maintained, with input from commercial software vendors, by the World Wide Web Consortium (W3C). In 2000, HTML became an international standard ( ISO / IEC 15445:2000). HTML 4.01

1976-554: The following encodings are explicitly listed in the HTML standard itself, with reference to the Encoding Standard: The following additional encodings are listed in the Encoding Standard, and support for them is therefore also required: The following encodings are listed as explicit examples of forbidden encodings: The standard also defines a "replacement" decoder, which maps all content labelled as certain encodings to

2028-453: The format & name ; where name is a case-sensitive alphanumeric string. For example, "λ" can also be encoded as &lambda; in an HTML document. The character entity references &lt; , &gt; , &quot; and &amp; are predefined in HTML and SGML, because < , > , " and & are already used to delimit markup. This notably did not include XML's &apos; (') entity prior to HTML5 . For

2080-412: The head, for example: HTML headings are defined with the < h1 > to < h6 > tags with H1 being the highest (or most important) level and H6 the least: The effects are: CSS can substantially change the rendering. Paragraphs: < br /> . The difference between < br /> and < p > is that < br /> breaks a line without altering

2132-425: The hyperlink tag, these were strongly influenced by SGMLguid , an in-house Standard Generalized Markup Language (SGML)-based documentation format at CERN. Eleven of these elements still exist in HTML 4. HTML is a markup language that web browsers use to interpret and compose text, images, and other material into visible or audible web pages. Default characteristics for every item of HTML markup are defined in

Character encodings in HTML - Misplaced Pages Continue

2184-402: The inline < img > tag. The name of an HTML element is the name used in the tags. The end tag's name is preceded by a slash character, / , and that in empty elements the end tag is neither required nor allowed. If attributes are not mentioned, default values are used in each case. Header of the HTML document: < head > ... </ head > . The title is included in

2236-462: The look and layout of content. The World Wide Web Consortium (W3C), former maintainer of the HTML and current maintainer of the CSS standards, has encouraged the use of CSS over explicit presentational HTML since 1997. A form of HTML, known as HTML5 , is used to display video and audio, primarily using the < canvas > element, together with JavaScript. In 1980, physicist Tim Berners-Lee ,

2288-413: The page. Other tags such as < p > and </ p > surround and provide information about document text and may include sub-element tags. Browsers do not display the HTML tags but use them to interpret the content of the page. HTML can embed programs written in a scripting language such as JavaScript , which affects the behavior and content of web pages. The inclusion of CSS defines

2340-480: The permitted and prohibited content for a document conforming to such a DTD. Browsers, on the other hand, do not implement HTML as an application of SGML and as consequence do not read the DTD. HTML5 does not define a DTD; therefore, in HTML5 the doctype declaration is simpler and shorter: An example of an HTML 4 doctype This declaration references the DTD for the "strict" version of HTML 4.01. SGML-based validators read

2392-412: The presentation of the document, and for some tags such as the < img > used to embed images, the reference to the image resource in the format like this: < img src = "example.com/example.jpg" > Some elements, such as the line break < br /> do not permit any embedded content, either text or further tags. These require only a single empty tag (akin to

2444-486: The project was not formally adopted by CERN. In his personal notes of 1990, Berners-Lee listed "some of the many areas in which hypertext is used"; an encyclopedia is the first entry. The first publicly available description of HTML was a document called "HTML Tags", first mentioned on the Internet by Tim Berners-Lee in late 1991. It describes 18 elements comprising the initial, relatively simple design of HTML. Except for

2496-657: The reader will nonetheless see the page as the creator intended, but other readers on different platforms or with different native languages will not see the page as intended. The WHATWG Encoding Standard, referenced by recent HTML standards (the current WHATWG HTML Living Standard, as well as the formerly competing W3C HTML 5.0 and 5.1) specifies a list of encodings which browsers must support. The HTML standards forbid support of other encodings. The Encoding Standard further stipulates that new formats, new protocols (even when existing formats are used) and authors of new documents are required to use UTF-8 exclusively. Besides UTF-8,

2548-468: The semantic structure of the page, whereas < p > sections the page into paragraphs . The element < br /> is an empty element in that, although it may have attributes, it can take no content and it may not have an end tag. This is a link in HTML. To create a link the < a > tag is used. The href attribute holds the URL address of the link. There are many possible ways

2600-517: The text between < body > and </ body > is the visible page content. The markup text < title > This is a title </ title > defines the browser page title shown on browser tabs and window titles and the tag < div > defines a division of the page used for easy styling. Between < head > and </ head > , a < meta > element can be used to define webpage metadata. The Document Type Declaration <!DOCTYPE html>

2652-583: Was not seen as feasible for them since they are comparatively more frequently used in deployed content. The following encodings receive this treatment: In addition to native character encodings, characters can also be encoded as character references , which can be numeric character references ( decimal or hexadecimal ) or character entity references . Character entity references are also sometimes referred to as named entities , or HTML entities for HTML. HTML's usage of character references derives from SGML . A numeric character reference in HTML refers to

SECTION 50

#1732858635813

2704-496: Was published in late 1999, with further errata published through 2001. In 2004, development began on HTML5 in the Web Hypertext Application Technology Working Group (WHATWG), which became a joint deliverable with the W3C in 2008, and was completed and standardized on 28 October 2014. XHTML is a separate language that began as a reformulation of HTML 4.01 using XML 1.0. It is now referred to as

#812187