Home > Web Front-end > HTML Tutorial > How to display special symbols in HTML5

How to display special symbols in HTML5

青灯夜游
Release: 2023-01-03 09:28:30
Original
8002 people have browsed it
<blockquote><p>在HTML5中,特殊符号可以通过“字符实体”来显示。HTML中一些特殊符号是无法直接使用显示的,例如“<”和“>”,浏览器会误认为它们是标签;此时就可以使用字符实体“<”和“>”来显示它们。<!--”和“--></p></blockquote> <p><img src="https://img.php.cn/upload/article/202103/08/2021030811302452454.jpg" alt="How to display special symbols in HTML5" ></p> <p>本教程操作环境:windows7系统、HTML5版、Dell G3电脑。</p> <p>在 HTML 中,某些字符是预留的。</p> <p>在 HTML 中不能使用小于号(<)和大于号(>),这是因为浏览器会误认为它们是标签。</p> <p>如下面的html代码:</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:html;toolbar:false;"> &lt;body&gt; 显示:&lt;input id=&quot;myTest&quot; type=&quot;text&quot; value=&quot;5&lt;=6&quot; &gt;&lt;/input&gt; &lt;/body&gt;</pre><div class="contentsignin">Copy after login</div></div><p>上面的value属性值中含有“<”,浏览器可能会正常显示,但是在解析的时候可能就会出错。</p><p>如果希望正确地显示预留字符,我们必须在 HTML 源代码中使用字符实体(character entities)。 字符实体类似这样:</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false">&amp;entity_name; 或 &amp;#entity_number;</pre><div class="contentsignin">Copy after login</div></div><p>如需显示小于号,我们必须这样写:&lt; 或 &#60; 或 &#060;</p> <p>提示: 使用实体名而不是数字的好处是,名称易于记忆。不过坏处是,浏览器也许并不支持所有实体名称(对实体数字的支持却很好)。</p> <p>(相关推荐:<a href="https://www.php.cn/div-tutorial.html" target="_blank">html教程</a> )</p> <p><span style="font-size: 18px;"><strong>特殊字符对应表</strong></span></p> <p>下面附上特殊字符对应表</p> <table> <thead><tr class="firstRow"> <th>字符</th> <th>十进制字符编号</th> <th>实体名字</th> </tr></thead> <tbody> <tr> <td><code>!</code></td> <td><code>&amp;#33;</code></td> <td>惊叹号Exclamation mark</td> </tr> <tr> <td><code>”</code></td> <td> <code>&amp;#34; &amp;quot;</code> 双引号Quotation mark</td> <td> </td> </tr> <tr> <td><code>#</code></td> <td><code>&amp;#35;</code></td> <td>数字标志Number sign</td> </tr> <tr> <td><code>$</code></td> <td><code>&amp;#36;</code></td> <td>美元标志Dollar sign</td> </tr> <tr> <td><code>%</code></td> <td><code>&amp;#37;</code></td> <td>百分号Percent sign</td> </tr> <tr> <td><code>&</code></td> <td><code>&#38; &amp;</code></td> <td>Ampersand</td> </tr> <tr> <td><code>‘</code></td> <td><code>&#39;</code></td> <td>单引号Apostrophe</td> </tr> <tr> <td><code>(</code></td> <td><code>&#40;</code></td> <td>小括号左边部分Left parenthesis</td> </tr> <tr> <td><code>)</code></td> <td><code>&#41;</code></td> <td>小括号右边部分Right parenthesis</td> </tr> <tr> <td><code>*</code></td> <td><code>&#42;</code></td> <td>星号Asterisk</td> </tr> <tr> <td><code>+</code></td> <td><code>&#43;</code></td> <td>加号Plus sign</td> </tr> <tr> <td><code>,</code></td> <td><code>&#44;</code></td> <td>逗号Comma</td> </tr> <tr> <td><code>–</code></td> <td><code>&#45;</code></td> <td>连字号Hyphen</td> </tr> <tr> <td><code>.</code></td> <td><code>&#46;</code></td> <td>句号Period (fullstop)</td> </tr> <tr> <td><code>/</code></td> <td><code>&#47;</code></td> <td>斜杠Solidus (slash)</td> </tr> <tr> <td><code>0</code></td> <td><code>&#48;</code></td> <td>数字0 Digit 0</td> </tr> <tr> <td><code>1</code></td> <td><code>&#49;</code></td> <td>数字1 Digit 1</td> </tr> <tr> <td><code>2</code></td> <td><code>&#50;</code></td> <td>数字2 Digit 2</td> </tr> <tr> <td><code>3</code></td> <td><code>&#51;</code></td> <td>数字3 Digit 3</td> </tr> <tr> <td><code>4</code></td> <td><code>&#52;</code></td> <td>数字4 Digit 4</td> </tr> <tr> <td><code>5</code></td> <td><code>&#53;</code></td> <td>数字5 Digit 5</td> </tr> <tr> <td><code>6</code></td> <td><code>&#54;</code></td> <td>数字6 Digit 6</td> </tr> <tr> <td><code>7</code></td> <td><code>&#55;</code></td> <td>数字7 Digit 7</td> </tr> <tr> <td><code>8</code></td> <td><code>&#56;</code></td> <td>数字8 Digit 8</td> </tr> <tr> <td><code>9</code></td> <td><code>&#57;</code></td> <td>数字9 Digit 9</td> </tr> <tr> <td><code>:</code></td> <td><code>&#58;</code></td> <td>冒号Colon</td> </tr> <tr> <td><code>;</code></td> <td><code>&#59;</code></td> <td>分号Semicolon</td> </tr> <tr> <td><code><</code></td><td><code>&#60; &lt;</code></td><td>小于号Less than</td></tr><tr><td><code>=</code></td><td><code>&#61;</code></td><td>等于符号Equals sign</td></tr><tr><td><code>></code></td> <td><code>&#62; &gt;</code></td> <td>大于号Greater than</td> </tr> <tr> <td><code>?</code></td> <td><code>&#63;</code></td> <td>问号Question mark</td> </tr> <tr> <td><code>@</code></td> <td><code>&#64;</code></td> <td>Commercial at</td> </tr> <tr> <td><code>A</code></td> <td><code>&#65;</code></td> <td>大写A Capital A</td> </tr> <tr> <td><code>B</code></td> <td><code>&#66;</code></td> <td>大写B Capital B</td> </tr> <tr> <td><code>C</code></td> <td><code>&#67;</code></td> <td>大写C Capital C</td> </tr> <tr> <td><code>D</code></td> <td><code>&#68;</code></td> <td>大写D Capital D</td> </tr> <tr> <td><code>E</code></td> <td><code>&#69;</code></td> <td>大写E Capital E</td> </tr> <tr> <td><code>F</code></td> <td><code>&#70;</code></td> <td>大写F Capital F</td> </tr> <tr> <td><code>G</code></td> <td><code>&#71;</code></td> <td>大写G Capital G</td> </tr> <tr> <td><code>H</code></td> <td><code>&#72;</code></td> <td>大写H Capital H</td> </tr> <tr> <td><code>I</code></td> <td><code>&#73;</code></td> <td>大写J Capital I</td> </tr> <tr> <td><code>J</code></td> <td><code>&#74;</code></td> <td>大写K Capital J</td> </tr> <tr> <td><code>K</code></td> <td><code>&#75;</code></td> <td>大写L Capital K</td> </tr> <tr> <td><code>L</code></td> <td><code>&#76;</code></td> <td>大写K Capital L</td> </tr> <tr> <td><code>M</code></td> <td><code>&#77;</code></td> <td>大写M Capital M</td> </tr> <tr> <td><code>N</code></td> <td><code>&#78;</code></td> <td>大写N Capital N</td> </tr> <tr> <td><code>O</code></td> <td><code>&#79;</code></td> <td>大写O Capital O</td> </tr> <tr> <td><code>P</code></td> <td><code>&#80;</code></td> <td>大写P Capital P</td> </tr> <tr> <td><code>Q</code></td> <td><code>&#81;</code></td> <td>大写Q Capital Q</td> </tr> <tr> <td><code>R</code></td> <td><code>&#82;</code></td> <td>大写R Capital R</td> </tr> <tr> <td><code>S</code></td> <td><code>&#83;</code></td> <td>大写S Capital S</td> </tr> <tr> <td><code>T</code></td> <td><code>&#84;</code></td> <td>大写T Capital T</td> </tr> <tr> <td><code>U</code></td> <td><code>&#85;</code></td> <td>大写U Capital U</td> </tr> <tr> <td><code>V</code></td> <td>##V<code></code> </td> Capital V Capital V<td></td> </tr> <tr>##W<td><code></code></td>W<td> <code></code>Capital W Capital W</td> <td></td> </tr> <tr>X<td><code></code></td>X<td> <code></code> Capital X Capital X</td> <td></td> </tr> <tr>Y<td><code></code></td>Y<td> <code></code>Capital Y Capital Y</td> <td></td> </tr>##Z<tr> <td><code>## Z</code></td> <td>Capital Z Capital Z<code></code> </td> <td></td>[</tr> <tr> <td><code>[</code></td> <td>Left square bracket<code></code> </td> <td></td>\</tr> <tr> <td> <code>\</code> </td> <td>BackslashReverse solidus (backslash)<code></code> </td> <td>##]</td> </tr> <tr>##]<td> <code></code>Right square bracket</td> <td><code></code></td>^<td></td> </tr> <tr>^<td> <code> </code>Caret</td> <td><code></code></td>_<td></td> </tr> <tr>_<td> <code></code>underscoreHorizontal bar (underscore )</td> <td><code></code></td>`<td></td> </tr>##`<tr> <td> <code>Acute accent</code> </td> <td> <code></code>a</td> <td></td>##a</tr> <tr> <td>lowercase a Small a<code></code> </td> <td><code>b</code></td> <td></td>b</tr> <tr> <td>lowercase b Small b<code></code> </td> <td><code>c</code></td> <td></td>c</tr> <tr> <td>lowercase c Small c<code></code> </td> <td><code>d</code></td> <td> </td>d</tr> <tr> <td>small d Small d<code></code> </td> <td>##e<code></code> </td>##e <td></td> </tr> Lower case e Small e<tr> <td><code></code></td>f<td><code></code></td>f<td></td> </tr> Lowercase f Small f<tr> <td><code></code></td>g<td> <code></code>##g</td> <td></td>lowercase g Small g</tr> <tr> <td> <code></code>h</td> <td><code>##h</code></td> <td>small h Small h</td> </tr> <tr> <td><code>i</code></td> <td>##i<code></code> </td>lowercase i Small i<td></td> </tr> <tr> <td>j<code></code> </td> <td>j<code></code> </td>小 j Small j<td></td> </tr> <tr>##k<td> <code></code> </td>k<td> <code></code>lowercase k Small k</td> <td></td> </tr> <tr>l<td><code></code></td>l<td> <code></code>小l Small l</td> <td></td> </tr>##m<tr> <td><code>##& #109;</code></td> <td>lowercase m Small m<code></code> </td> <td></td>n</tr> <tr> <td><code>n</code></td> <td> Lowercase n Small n<code></code> </td> <td></td>o</tr> <tr> <td>##o<code></code> </td> Lowercase o Small o<td><code></code></td> <td>p</td> </tr> <tr> <td>p<code></code> </td>lowercase p Small p<td><code></code></td> <td>q</td> </tr> <tr>##q<td> <code></code>small q Small q</td> <td><code></code></td>r<td></td> </tr>##r<tr> <td><code>small r Small r</code></td> <td> <code></code>s</td> <td></td> </tr>s<tr> <td><code> Lowercase s Small s</code></td> <td> <code></code>t</td> <td></td> </tr>t<tr> <td><code>small t Small t</code></td> <td> <code></code>u</td> <td></td> </tr>u<tr> <td><code>lowercase u Small u</code></td> <td> <code></code>v</td> <td></td> </tr>v<tr> <td><code>small v Small v</code></td> <td><code>##w</code></td> <td>##& #119;</td> </tr> <tr>lowercase w Small w<td><code></code></td> <td>x<code></code> </td> <td>x</td> </tr> <tr>Lower case x Small x<td><code></code></td> <td>y<code></code> </td>##y<td></td> </tr> Lowercase y Small y<tr> <td><code></code></td>z<td><code></code></td>z<td></td> </tr>lowercase z Small z<tr> <td> <code></code>##{</td> <td> <code></code>{</td> <td></td>Left curly brace</tr> <tr> <td><code>|</code></td> <td>|<code></code> </td>Vertical bar<td></td> </tr> <tr># #}<td><code>}</code></td> <td>Right curly brace</td> </tr> <tr> <td>##~<code></code> </td> <td>~<code></code> </td>Tilde<td></td> </tr> <tr> <td>—<code></code> </td> <td><code></code> </td>Unused<td></td> </tr> <tr> <td></td> <td>   <code></code> </td>Nonbreaking space<td></td> </tr> <tr> <td>¡ <code></code> </td> <td>¡ ¡<code></code> </td>Inverted exclamation<td></td> </tr> <tr> <td>¢<code></code> </td> <td>¢ ¢<code></code> </td>Cent sign<td></td> </tr> <tr> <td>£<code></code> </td> <td>£ £<code></code> </td> Pound sterling<td></td> </tr> <tr> <td>¤<code></code> </td> <td>¤ ¤<code></code> </td>General currency sign<td></td> </tr> <tr> <td>¥<code></code> </td># #¥ ¥<td> <code></code>Yen mark</td> <td></td> </tr>##¦<tr> <td><code>##¦ ; ¦</code></td> <td>or &brkbar;“`<code></code> </td> <td>##§</td> </tr> <tr>##§ &sect ;<td> <code></code>Section sign</td> <td><code></code></td>¨<td></td> </tr>##¨ ¨<tr> <td><code>or ¨“`</code></td> <td> <code></code>©</td> <td></td> </tr>© ©<tr> <td><code>Copyright logoCopyright</code></td> <td><code>##ª</code></td> <td>##ª ª</td> </tr> <tr>Feminine ordinal<td><code></code></td> <td>«<code></code> </td>##« «<td></td> </tr>Left angle quote, guillemet left<tr> <td><code></code></td>¬<td> <code></code>“`¬ ¬</td> <td>Not sign</td> </tr> <tr> <td>“““<code></code> </td>­ ­<td></td> <td>Soft hyphen</td> </tr> <tr> <td>##®</td> <td> <code></code>® ®</td> <td></td>Registered trademark</tr> <tr> <td><code>##¯</code></td> <td><code>¯ ¯</code></td> <td>or &hibar;“`</td> </tr> <tr> <td>##°<code></code> </td> <td>° °<code></code> </td>Degree sign<td></td> </tr> <tr> <td>±<code></code> </td> <td>± ±<code></code> </td>Plus or minus<td></td> </tr> <tr> <td>²<code></code> </td> <td> ² ²<code></code> </td>Superscript two<td></td> </tr> <tr> <td>³<code></code> </td> <td> 179; ³<code></code> </td>Superscript three<td></td> </tr> <tr> <td>´<code></code> </td>##´ ´<td> <code></code>Acute accent</td> <td></td> </tr> <tr>µ<td><code></code></td>µ µ <td> <code></code>Micro sign</td> <td></td> </tr> <tr>¶<td> <code></code>##¶ ¶</td> <td><code>Paragraph sign</code></td> <td></td> </tr>·<tr> <td><code>##· ·</code></td> <td>Middle dot<code></code> </td> <td>##¸</td> </tr> <tr> <td>¸ ¸<code></code> </td>Cedilla<td><code></code></td> <td>¹</td> </tr> <tr>##¹<td> <code></code>Superscript one</td> <td><code></code></td>º<td></td> </tr>##º º<tr> <td><code>Masculine ordinal</code></td> <td> <code> </code>»</td> <td></td> </tr>» »<tr> <td><code>Right angle quote, guillemet right</code></td> <td> <code></code>¼</td> <td></td>##¼ ¼</tr> <tr> <td>Fraction one-fourth<code></code> </td> <td> <code>½</code> </td> <td></td>½ ½</tr> <tr> <td>Fraction one-half<code></code> </td> <td><code>¾</code></td> <td></td>¾ ¾</tr> <tr> <td>Fraction three-fourths<code></code> </td> <td><code>¿ </code></td> <td></td>¿ ¿</tr> <tr> <td>Inverted question mark<code></code> </td> <td>##À<code></code> </td> <td>À À</td> </tr> <tr>Capital A, grave accent<td><code></code></td>##Á<td><code> </code></td>Á Á<td></td> </tr>Capital A, acute accent<tr> <td> <code></code>##Â</td> <td> <code></code> Â</td> <td></td>Capital A, circumflex</tr> <tr> <td><code>##Ã</code></td> <td><code>à Ã</code></td> <td>Capital A, tilde</td> </tr> <tr> <td>##Ä<code></code> </td> <td> 196; Ä<code></code> </td>Capital A, di?esis / umlaut<td></td> </tr> <tr> <td>Å<code></code> </td> <td>& #197; Å<code></code> </td>Capital A, ring<td></td> </tr> <tr>##Æ<td> <code></code>##Æ Æ</td> <td><code>Capital AE ligature</code></td> <td></td> </tr>Ç<tr> <td> <code></code>Ç Ç</td> <td><code>Capital C, cedilla</code></td> <td></td>##È</tr> <tr> <td><code>È È</code></td> <td>Capital E, grave accent<code></code> </td> <td></td>É</tr> <tr> <td>##É É<code></code> </td>Capital E, acute accent<td><code></code></td>##Ê<td></td> </tr>##Ê Ê<tr> <td><code> Capital E, circumflex</code></td> <td><code>##Ë</code></td> <td></td>Ë Ë</tr> <tr><td>Capital E, di?esis / umlaut<code></code> </td></tr> <tr> <td><code>Ì</code></td> <td><code>Ì Ì</code></td> <td>Capital I, grave accent</td> </tr> <tr> <td><code>Í</code></td> <td><code>Í Í</code></td> <td>Capital I, acute accent</td> </tr> <tr> <td><code>Î</code></td> <td><code>Î Î</code></td> <td>Capital I, circumflex</td> </tr> <tr> <td><code>Ï</code></td> <td><code>Ï Ï</code></td> <td>Capital I, di?esis / umlaut</td> </tr> <tr> <td><code>Ð</code></td> <td><code>Ð Ð</code></td> <td>Capital Eth, Icelandic</td> </tr> <tr> <td><code>Ñ</code></td> <td><code>Ñ Ñ</code></td> <td>Capital N, tilde</td> </tr> <tr> <td><code>Ò</code></td> <td><code>Ò Ò</code></td> <td>Capital O, grave accent</td> </tr> <tr> <td><code>Ó</code></td> <td><code>Ó Ó</code></td> <td>Capital O, acute accent</td> </tr> <tr> <td><code>Ô</code></td> <td><code>Ô Ô</code></td> <td>Capital O, circumflex</td> </tr> <tr> <td><code>Õ</code></td> <td><code>Õ Õ</code></td> <td>Capital O, tilde</td> </tr> <tr> <td><code>Ö</code></td> <td><code>Ö Ö</code></td> <td>Capital O, di?esis / umlaut</td> </tr> <tr> <td><code>×</code></td> <td><code>× ×</code></td> <td>乘号Multiply sign</td> </tr> <tr> <td><code>Ø</code></td> <td><code>Ø Ø</code></td> <td>Capital O, slash</td> </tr> <tr> <td><code>Ù</code></td> <td><code>Ù Ù</code></td> <td>Capital U, grave accent</td> </tr> <tr> <td><code>Ú</code></td> <td><code>Ú Ú</code></td> <td>Capital U, acute accent</td> </tr> <tr> <td><code>Û</code></td> <td><code>Û Û</code></td> <td>Capital U, circumflex</td> </tr> <tr> <td><code>Ü</code></td> <td><code>Ü Ü</code></td> <td>Capital U, di?esis / umlaut</td> </tr> <tr> <td><code>Ý</code></td> <td><code>Ý Ý</code></td> <td>Capital Y, acute accent</td> </tr> <tr> <td><code>Þ</code></td> <td><code>Þ Þ</code></td> <td>Capital Thorn, Icelandic</td> </tr> <tr> <td><code>ß</code></td> <td><code>ß ß</code></td> <td>Small sharp s, German sz</td> </tr> <tr> <td><code>à</code></td> <td><code>à à</code></td> <td>Small a, grave accent</td> </tr> <tr> <td><code>á</code></td> <td><code>á á</code></td> <td>Small a, acute accent</td> </tr> <tr> <td><code>â</code></td> <td><code>â â</code></td> <td>Small a, circumflex</td> </tr> <tr> <td><code>ã</code></td> <td><code>ã ã</code></td> <td>Small a, tilde</td> </tr> <tr> <td><code>ä</code></td> <td><code>ä ä</code></td> <td>Small a, di?esis / umlaut</td> </tr> <tr> <td><code>å</code></td> <td><code>å å</code></td> <td>Small a, ring</td> </tr> <tr> <td><code>æ</code></td> <td><code>æ æ</code></td> <td>Small ae ligature</td> </tr> <tr> <td><code>ç</code></td> <td><code>ç ç</code></td> <td>Small c, cedilla</td> </tr> <tr> <td><code>è</code></td> <td><code>è è</code></td> <td>Small e, grave accent</td> </tr> <tr> <td><code>é</code></td> <td><code>é é</code></td> <td>Small e, acute accent</td> </tr> <tr> <td><code>ê</code></td> <td><code>ê ê</code></td> <td>Small e, circumflex</td> </tr> <tr> <td><code>ë</code></td> <td><code>ë ë</code></td> <td>Small e, di?esis / umlaut</td> </tr> <tr> <td><code>ì</code></td> <td><code>ì ì</code></td> <td>Small i, grave accent</td> </tr> <tr> <td><code>í</code></td> <td><code>í í</code></td> <td>Small i, acute accent</td> </tr> <tr> <td><code>î</code></td> <td><code>î î</code></td> <td>Small i, circumflex</td> </tr> <tr> <td><code>ï</code></td> <td><code>ï ï</code></td> <td>Small i, di?esis / umlaut</td> </tr> <tr> <td><code>ð</code></td> <td><code>ð ð</code></td> <td>Small eth, Icelandic</td> </tr> <tr> <td><code>ñ</code></td> <td><code>ñ ñ</code></td> <td>Small n, tilde</td> </tr> <tr> <td><code>ò</code></td> <td><code>ò ò</code></td> <td>Small o, grave accent</td> </tr> <tr> <td><code>ó</code></td> <td><code>ó ó</code></td> <td>Small o, acute accent</td> </tr> <tr> <td><code>ô</code></td> <td><code>ô ô</code></td> <td>Small o, circumflex</td> </tr> <tr> <td><code>õ</code></td> <td><code>õ õ</code></td> <td>Small o, tilde</td> </tr> <tr> <td><code>ö</code></td> <td><code>ö ö</code></td> <td>Small o, di?esis / umlaut</td> </tr> <tr> <td><code>÷</code></td> <td><code>÷ ÷</code></td> <td>除号Division sign</td> </tr> <tr> <td><code>ø</code></td> <td><code>ø ø</code></td> <td>Small o, slash</td> </tr> <tr> <td><code>ù</code></td> <td><code>ù ù</code></td> <td>Small u, grave accent</td> </tr> <tr> <td><code>ú</code></td> <td>##ú ú<code></code> </td>Small u, acute accent<td></td> </tr> <tr> <td>û<code></code> </td>##û û<td> <code></code>Small u, circumflex</td> <td></td> </tr>##ü<tr> <td> <code></code>ü ü</td> <td><code>Small u, di?esis / umlaut</code></td> <td></td> </tr>ý<tr> <td> <code></code>ý ý</td> <td><code>Small y, acute accent</code></td> <td></td> </tr> <tr> <td> <code></code>þ þ</td> <td><code>Small thorn, Icelandic</code></td> <td></td> </tr> ÿ<tr> <td><code>##ÿ ÿ</code></td> <td>Small y, umlaut<code></code> </td> <td></td>More Programming For related knowledge, please visit: </tr>programming video</tbody>! ! </table>

The above is the detailed content of How to display special symbols in HTML5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template