HTML 转义字符(escape characters)及其对应的符号(symbols)

以下是常见的 HTML 转义字符及其对应的符号,这些可以用于在 HTML 或 JSX 中避免解析错误和特殊字符的冲突:

  1. 空格 ( ):

    •   
  2. 引号:

    • 单引号('):'‘'’
    • 双引号("):""
  3. 大于号(>):

    • >>
  4. 小于号(<):

    • &lt;&#60;
  5. 和号(&):

    • &amp;&#38;
  6. 分号(;):

    • &semi;&#59;
  7. 逗号(,):

    • &comma;&#44;
  8. 其他常见符号:

    • 符号(©):&copy;&#169;
    • 商标符号(®):&reg;&#174;
    • 欧元符号(€):&euro;&#8364;
    • 美元符号($):&#36;
    • 分数(½):&frac12;&#189;
    • 换行(换行符):&NewLine;

这些转义字符可以帮助你在 HTML 和 JSX 中正确显示特殊符号,而不会因为符号的特殊含义引起解析错误。下面是一个示例,展示如何在 JSX 中使用这些转义字符:

<h1 className="title p-6 text-4xl">
  <b>Hey, Hayley&apos;s blogs are here! &copy; 2024</b> Discover my creative designs, please!
  <p>Use the euro symbol: &euro;, and the less than symbol: &lt;.</p>
</h1>

Here are the common HTML escape characters and their corresponding symbols, which you can use in HTML or JSX to avoid parsing errors and conflicts with special characters:

  1. Space ( ):

    • &nbsp; or &#160;
  2. Quotes:

    • Single quote ('): &apos;, &lsquo;, &#39;, &rsquo;
    • Double quote ("): &quot; or &#34;
  3. Greater-than sign (>):

    • &gt; or &#62;
  4. Less-than sign (<):

    • &lt; or &#60;
  5. Ampersand (&):

    • &amp; or &#38;
  6. Semicolon (;):

    • &semi; or &#59;
  7. Comma (,):

    • &comma; or &#44;
  8. Other common symbols:

    • Copyright symbol (©): &copy; or &#169;
    • Registered trademark symbol (®): &reg; or &#174;
    • Euro symbol (): &euro; or &#8364;
    • Dollar sign ($): &#36;
    • Fraction (½): &frac12; or &#189;
    • Newline (line break): &NewLine;

These escape characters ensure that special symbols are displayed correctly in your HTML or JSX without causing parsing errors.

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值