1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu HTML & CSS: The Complete Reference- P16 pdf

50 388 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 0,93 MB

Nội dung

This page intentionally left blank Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. A Character Entities K eyboard characters such as < and > have special meanings to (X)HTML because they are part of HTML tags and must be encoded. Other characters, such as certain foreign language accent characters and special symbols, can be difficult to specify, depending on the keyboard being used. To address escaping of special-purpose characters and inserting a wide range of characters and symbols, character entities should be employed. The format of character entities is in general &code; where code may be a • A decimal form like &#203; • A hex form like &#x00CB; or stripped of leading zeros, simply &xCB; • A named value if available, such as &Euml; NOTE When using a hex form, either a lowercase or uppercase x may be used as well as upper- and lowercase values for digits A–F, so &#XCB; and &#xCB; and &#xCb; and so on are all equivalent. Case sensitivity is not, however, guaranteed for named entities and may result in errors or wrong characters. Good style would suggest lowercase for the hex symbol and uppercase for the digits. As an example, <p>Numeric entity decimal: &#163;</p> <p>Numeric entity hex: &#x00A3;</p> <p>Named entity: &pound;</p> 727 727 APPENDIX Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 728 P a r t I I I : A p p e n d i x e s 728 P a r t I I I : A p p e n d i x e s would look like this: Encoding Quirks and Considerations Encoding characters is quite important if you want to validate your markup. For example, consider when you have nontrivial query strings in (X)HTML links like so: <p>Does this <a href="http://www.pint.com/program?p1=foo&p2=bar">link</a> validate?</p> The markup will not validate. For this line to validate, you must encode the special characters in the link like so: <p>Does this <a href="http://www.pint.com/program?p1=foo&amp;p2=bar">link</a> validate?</p> Do not, however, take this as advice to change ampersands in typed URLs everywhere you encounter them, such as within e-mails or the browser’s location bar. Typically, a browser will exchange an entity for its correct value, but this change may not take place in other environments. Commonly, you will also have trouble when using characters that are part of (X)HTML itself, particularly the less than (<) and greater than (>) symbols and, of course, the ampersand that starts entities. As an example, consider this contrived example with a mathematical expression: <p>A silly math statement ahead x<y>z is dangerous to validation.</p> Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. A p p e n d i x A : C h a r a c t e r E n t i t i e s 729 PART III A p p e n d i x A : C h a r a c t e r E n t i t i e s 729 For the greatest safety, the markup should have had the special characters encoded like so: <p>A silly math statement ahead x&lt;y&gt;z is not dangerous to validation.</p> We note that this example is fairly contrived and often just an extra space will allow the validator (and browser) to tokenize the text correctly. For example, <p>A silly math statement ahead x < y > z is dangerous to validation?</p> will likely validate. The loose enforcement of special character handling is both a blessing and a curse. It leads to sloppy usage and surprising bugs. Sloppy syntax is troubling because interpretation may vary browser to browser. Consider the point of case sensitivity of named entities in browsers. Named entities are supposed to be case sensitive. For example, &agrave; and &Agrave; are two different characters. Now given this fact, what should a browser do when faced with <p>&POUND; and &pound;</p> Apparently it treats the first as text and the second as an entity. But does that hold for all characters? Apparently not—some entities like &copy; are generally case insensitive, while others like &trade; may vary by browser, and others like &yen; will always be case sensitive. Initial drafts of HTML5 attempted to formalize what named entities should be case insensitive; these drafts focused on the commonly used and supported entities. The current list of what should be case-insensitive named entities is shown in Table A-1. Best practice, however, would be not to r ely on case insensitivity of named entities, it is still inconsistent. In general, lax syntax enforcement and permissive interpretation of entities in browsers just leads to all sorts of small quirks. Consider <p>&QUOTE; and &quote;</p> Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 730 P a r t I I I : A p p e n d i x e s 730 P a r t I I I : A p p e n d i x e s Under Internet Explorer, the rendering engine even in a strict mode will “fix” this problem and effectively convert this into <p>&QUOT;E; and &quot;e;</p> while other browsers will correctly leave this mistake alone. While it turns out that SGML (and thus traditional HTML) does allow the final semicolon to be left off in an entity in some cases, the preceding example clearly indicates it does not allow for that latitude in the middle of words. Just as when dealing with markup and CSS, it is best to get syntax right rather than rely on some variable fix-up applied by a browser’s rendering engine. There will be instances when you may get the syntax correct but the browser may not be able to render the characters meaningfully. The reasons for nonsupport can vary and may be because a particular font is missing or the operating environment or browser is unable to render the character. Generally, browsers will present these failures as boxes or diamonds, like so: Named Entity HTML5 Alias Numbered Entity Unicode Entity Intended Rendering Description &amp; &AMP; &#38; &#x0026; & Ampersand &copy; &COPY; &#169; &#x00A9; © Copyright &gt; &GT; &#62; &#x003E; > Greater than &lt; &LT; &#60; &#x003C; < Less than &quot; &QUOT; &#34; &#x0022; “ Double quotes &reg; &REG; &#174; &#x00AE; ® Registration mark &trade; &TRADE; &#8482; &#x2122; ™ Trademark symbol TABLE A-1 Entities Considered Case Insensitive in HTML5 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. A p p e n d i x A : C h a r a c t e r E n t i t i e s 731 PART III A p p e n d i x A : C h a r a c t e r E n t i t i e s 731 Traditional HTML Entities Table A-2 lists the standard entities found in even the oldest versions of HTML and their intended renderings. This is the base set of characters supported by ASCII character sets, and future extensions for full ISO-8859-1 follow. In traditional HTML pages, authors may use this encoding, which may be specified in the HTTP header: Content-Type: text/html; charset=ISO-8859-1 Or more commonly, it will appear in a <meta> tag like so: <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> However, Web page authors are always encouraged to use the UTF-8 encoding set either by header, Content-Type: text/html; charset=utf-8 or by tag, <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> unless they have some overriding reason not to. Recognizing the move toward Unicode, we provide those values as well in all tables. However, given the vast range of the possible characters we only present those Unicode entities that are explicitly named in the (X)HTML specifications circa late 2009. For more information on Unicode, see the section entitled “Embracing Unicode” later in the appendix. CAUTION Entity values from 127 to 159 are not assigned. Web page authors are advised not to use them. Interestingly, some of these renderings are common, though they may work for only certain operating system font combinations. Table A-2 puts these values in italics to emphasize they should be avoided. NOTE The trademark character (™) may have concerns across browsers and operating system combinations, particularly archaic ones. Web page authors concerned with perfect backward compatibility might want to consider using a workaround such as <sup><small>TM </small></sup> for this symbol. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 732 P a r t I I I : A p p e n d i x e s 732 P a r t I I I : A p p e n d i x e s Named Entity Numbered Entity Unicode Entity Intended Rendering Description &#32; &#x0020; Space &#33; &#x0021; ! Exclamation point &quot; &#34; &#x0022; “ Double quotes &#35; &#x0023; # Number symbol &#36; &#x0024; $ Dollar symbol &#37; &#x0025; % Percent symbol &amp; &#38; &#x0026; & Ampersand &#39; &#x0027; ‘ Single quote &#40; &#x0028; ( Opening parenthesis &#41; &#x0029; ) Closing parenthesis &#42; &#x002A; * Asterisk &#43; &#x002B; + Plus sign &#44; &#x002C; , Comma &#45; &#x002D; - Minus sign (hyphen) &#46; &#x002E; . Period &#47; &#x002F; / Slash/virgule/bar &#48; &#x0030; 0 Zero &#49; &#x0031; 1 One &#50; &#x0032; 2 Two &#51; &#x0033; 3 Three &#52; &#x0034; 4 Four &#53; &#x0035; 5 Five &#54; &#x0036; 6 Six &#55; &#x0037; 7 Seven &#56; &#x0038; 8 Eight &#57; &#x0039; 9 Nine &#58; &#x003A; : Colon &#59; &#x003B; ; Semicolon &lt; &#60; &#x003C; < Less-than symbol &#61; &#x003D; = Equal sign TABLE A-2 Traditional HTML Character Entities Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. A p p e n d i x A : C h a r a c t e r E n t i t i e s 733 PART III A p p e n d i x A : C h a r a c t e r E n t i t i e s 733 Named Entity Numbered Entity Unicode Entity Intended Rendering Description &gt; &#62; &#x003E; > Greater-than symbol &#63; &#x003F; ? Question mark &#64; &#x0040; @ At symbol &#65; &#x0041; A Capital letter a &#66; &#x0042; B Capital letter b &#67; &#x0043; C Capital letter c &#68; &#x0044; D Capital letter d &#69; &#x0045; E Capital letter e &#70; &#x0046; F Capital letter f &#71; &#x0047; G Capital letter g &#72; &#x0048; H Capital letter h &#73; &#x0049; I Capital letter i &#74; &#x004A; J Capital letter j &#75; &#x004B; K Capital letter k &#76; &#x004C; L Capital letter l &#77; &#x004D; M Capital letter m &#78; &#x004E; N Capital letter n &#79; &#x004F; O Capital letter o &#80; &#x0050; P Capital letter p &#81; &#x0051; Q Capital letter q &#82; &#x0052; R Capital letter r &#83; &#x0053; S Capital letter s &#84; &#x0054; T Capital letter t &#85; &#x0055; U Capital letter u &#86; &#x0056; V Capital letter v &#87; &#x0057; W Capital letter w &#88; &#x0058; X Capital letter x &#89; &#x0059; Y Capital letter y &#90; &#x005A; Z Capital letter z &#91; &#x005B; [ Opening bracket &#92; &#x005C; \ Backslash TABLE A-2 Traditional HTML Character Entities (continued) Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 734 P a r t I I I : A p p e n d i x e s 734 P a r t I I I : A p p e n d i x e s Named Entity Numbered Entity Unicode Entity Intended Rendering Description &#93; &#x005D; ] Closing bracket &#94; &#x005E; ^ Caret &#95; &#x005F; _ Underscore &#96; &#x0060; ` Grave accent, no letter &#97; &#x0061; a Lowercase letter a &#98; &#x0062; b Lowercase letter b &#99; &#x0063; c Lowercase letter c &#100; &#x0064; d Lowercase letter d &#101; &#x0065; e Lowercase letter e &#102; &#x0066; f Lowercase letter f &#103; &#x0067; g Lowercase letter g &#104; &#x0068; h Lowercase letter h &#105; &#x0069; i Lowercase letter i &#106; &#x006A; j Lowercase letter j &#107; &#x006B; k Lowercase letter k &#108; &#x006C; l Lowercase letter l &#109; &#x006D; m Lowercase letter m &#110; &#x006E; n Lowercase letter n &#111; &#x006F; o Lowercase letter o &#112; &#x0070; p Lowercase letter p &#113; &#x0071; q Lowercase letter q &#114; &#x0072; r Lowercase letter r &#115; &#x0073; s Lowercase letter s &#116; &#x0074; t Lowercase letter t &#117; &#x0075; u Lowercase letter u &#118; &#x0076; v Lowercase letter v &#119; &#x0077; w Lowercase letter w &#120; &#x0078; x Lowercase letter x &#121; &#x0079; y Lowercase letter y &#122; &#x007A; z Lowercase letter z &#123; &#x007B; { Opening brace TABLE A-2 Traditional HTML Character Entities (continued) Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. A p p e n d i x A : C h a r a c t e r E n t i t i e s 735 PART III A p p e n d i x A : C h a r a c t e r E n t i t i e s 735 Named Entity Numbered Entity Unicode Entity Intended Rendering Description &#124; &#x007C; | Vertical bar &#125; &#x007D; } Closing brace &#126; &#x007E; ~ Equivalency symbol (tilde) &#127; &#x007F; No character &#128; &#x0080; € No character defined, typically Euro. However &euro; or &#8364; or &#x20AC; should be used instead. &#129; &#x0081; No character defined. Trademark symbol on some systems (nonstandard). Use &trade; or &#8482; instead. &#130; &#x0082; , Low-9 quote (nonstandard) &#131; &#x0083; ƒ Small “f” with hook (nonstandard) &#132; &#x0084; „ Low-9 double quotes (nonstandard) &#133; &#x0085; … Ellipsis (nonstandard) &#134; &#x0086; † Dagger (nonstandard) &#135; &#x0087; ‡ Double dagger (nonstandard) &#136; &#x0088; ^ Circumflex accent, no letter (nonstandard) &#137; &#x0089; ‰ Per mille (nonstandard) &#138; &#x008A; Š Uppercase S with caron (nonstandard) &#139; &#x008B; ‹ Opening single-angle quote (nonstandard) &#140; &#x008C; Œ Uppercase “OE” ligature (nonstandard) &#141; &#x008D; Ÿ No character, though for some uppercase “Y” with umlaut (nonstandard) &#142; &#x008E; Ž Uppercase “Z” with caron &#143; &#x008F; No character &#144; &#x0090; No character TABLE A-2 Traditional HTML Character Entities (continued) Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... pre-IE8 √ &# 8730; &# x221A; ∝ &# 8733; &# x221D Proportional to ∞ &# 8734; &# x221E; Infinity ∠ &# 8736; &# x2220; Angle No support pre-IE8 ∧ &# 8743; &# x2227; Logical and No support pre-IE8 ∨ &# 8744; &# x2228; Logical or No support pre-IE8 ∩ &# 8745; &# x2229; Intersection, cap ∪ &# 8746; &# x222A; Union, cup ∫ &# 8747; &# x222B; Integral ∴ &# 8756; &# x2234; Therefore... &# x00B1; Plus/minus symbol &# 178; &# x00B2; 2 Superscript 2 ³ &# 179; &# x00B3; 3 Superscript 3 ´ &# 180; &# x00B4; Acute accent, no letter µ &# 181; &# x00B5; à Micron ¶ &# 182; &# x00B6; ả Paragraph symbol · &# 183; &# x00B7; ã Middle dot ¸ &# 184; &# x00B8; á Cedilla ¹ &# 185; &# x00B9; 1 Superscript 1 º &# 186; &# x00BA; » &# 187; &# x00BB; ằ Masculine ordinal... Description ¨ &# 168; &# x00A8; ă Umlaut, no letter © &# 169; &# x00A9; â Copyright symbol ª &# 170; &# x00AA; a 737 Feminine ordinal indicator « &# 171; &# x00AB; ô Opening double-angle quote ¬ &# 172; &# x00AC; ơ Logical not symbol ­ &# 173; &# x00AD; - Soft hyphen ® &# 174; &# x00AE; đ Registration mark ¯ &# 175; &# x00AF; Macron ° &# 176; &# x00B0; Degree symbol &# 177; &# x00B1;... letter chi Χ &# 935; &# x03A7; Ψ &# 936; &# x03A8; Greek capital letter psi Ω &# 937; &# x03A9; Greek capital letter omega α &# 945; &# x03B1; Greek small letter alpha β &# 946; &# x03B2; Greek small letter beta γ &# 947; &# x03B3; Greek small letter gamma δ &# 948; &# x03B4; Greek small letter delta ε &# 949; &# x03B5; Greek small letter epsilon ζ &# 950; &# x03B6;... — &# 8212; &# x2014; Em dash ‘ &# 8216; &# x2018; Left single quotation mark ’ &# 8217; &# x2019; Right single quotation mark ‚ &# 8218; &# x201A; , Single low-9 quotation mark “ &# 8220; &# x201C; Left double quotation mark ” &# 8221; &# x201D; Right double quotation mark „ &# 8222; &# x201E; Double low-9 quotation mark † &# 8224; &# x2020; Dagger ‡ &# 8225;... mu ν &# 957; &# x03BD; Greek small letter nu ξ &# 958; &# x03BE; Greek small letter xi ο &# 959; &# x03BF; Greek small letter omicron Greek small letter pi π &# 960; &# x03C0; ρ &# 961; &# x03C1; Greek small letter rho ς &# 962; &# x03C2; Greek small letter final sigma σ &# 963; &# x03C3; Greek small letter sigma τ &# 964; &# x03C4; Greek small letter tau υ &# 965;... delta &# 917; &# x0395; Greek capital letter epsilon &# 918; &# x0396; Greek capital letter zeta Η &# 919; &# x0397; Greek capital letter eta Θ &# 920; &# x0398; Greek capital letter theta Ι &# 921; &# x0399; Greek capital letter iota Κ &# 922; &# x039A; Greek capital letter kappa Greek capital letter lambda Λ &# 923; &# x039B; Μ &# 924; &# x039C; Greek capital letter mu Ν &# 925;... &# 925; &# x039D; Greek capital letter nu Ξ &# 926; &# x039E; Greek capital letter xi Ο &# 927; &# x039F; Greek capital letter omicron Π &# 928; &# x03A0; Greek capital letter pi Ρ &# 929; &# x03A1; Greek capital letter rho Σ &# 931; &# x03A3; Greek capital letter sigma Τ &# 932; &# x03A4; Greek capital letter tau Υ &# 933; &# x03A5; Greek capital letter upsilon Φ &# 934; &# x03A6;... accent É &# 201; &# x00C9; ẫ Uppercase E with acute accent Ê &# 202; &# x00CA; ấ Uppercase E with circumflex Ë &# 203; &# x00CB; ậ Uppercase E with umlaut Ì &# 204; &# x00CC; è Uppercase I with grave accent Í &# 205; &# x00CD; Uppercase I with acute accent Î &# 206; &# x00CE; ẻ Uppercase I with circumflex Ï &# 207; &# x00CF; ẽ Uppercase I with umlaut Ð &# 208; &# x00D0;... Capital ETH Ñ &# 209; &# x00D1; ẹ Uppercase N with tilde Ò &# 210; &# x00D2; ề Uppercase O with grave accent Ó &# 211; &# x00D3; ể Uppercase O with acute accent Ô &# 212; &# x00D4; ễ Uppercase O with circumflex Õ &# 213; &# x00D5; ế Uppercase O with tilde Ö &# 214; &# x00D6; ệ Uppercase O with umlaut × &# 215; &# x00D7; ì Multiplication symbol Ø &# 216; &# x00D8; ỉ . (X )HTML links like so: <p>Does this <a href="http://www.pint.com/program?p1=foo&p2=bar">link</a> validate?</p> The. Description &amp; &AMP; &#38; &#x0026; & Ampersand &copy; &COPY; &#169; &#x00A9; © Copyright &gt; &GT; &#62; &#x003E;

Ngày đăng: 26/01/2014, 09:20

TỪ KHÓA LIÊN QUAN