CSS content 添加 HTML 实体

HTML 提供了一些显示保留字符的方法。保留字符是为 HTML 保留的字符或基本键盘中不存在的字符。例如:‘HTML 实体。

**示例:**本示例使用使用 CSS 的 HTML 实体在文档中添加一些内容。

更多教程请访问码农之家  

<!DOCTYPE HTML>
<html>

<head>

    <!--If you write HTML entities directly, then 
    it will not provide the desired result-->

    <!--If you add < symbol before the content,
    then it will not produce the desired result-->

    <!-- If you add > symbol after the content, 
    then it will not produce the desired result-->

    <style>
        h1:before {
            content:'<';
            color:'green';
        }
        h1:after {
            content:'>';
            color:'green';
        }
        h1 {
            color:green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeeks</h1>
</body>

</html>                    

示例 2: 本示例使用 CSS 添加大于号和小于号,然后使用其对应的转义 Unicode 添加大于号和小于号。

<!DOCTYPE HTML>
<html>

<head>
    <!--If you want to add < symbol before the content,
    then use its "Unicode<div id="practice"></div>" which is "003C"-->

    <!--If you want to add > symbol after the content,
    then use its "Unicode" which is "003E"-->

    <style>
        h1:before {
            content:'\003C';
            color:'green';
        }
        h1:after {
            content:'\003E';
            color:'green';
        }
        h1 {
            color:green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeeks</h1>
</body>

</html>                    

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值