这段代码解释了伪元素first-letter
,first-line
并且运行良好。
<html>
<head>
<title>Practice CSS :first-letter pseudo element </title>
</head>
<style type="text/css">
<!--
p:first-letter { font-size: 3em; text-color:red; }
p.normal:first-letter { font-size: 40px; color:red; }
p:first-line { text-decoration: none; }
p.line:first-line { text-decoration: underline; }
-->
</style>
<body>
<p class="normal"> First character of this paragraph will
be normal and will have font size 40 px;</p>
<p class="line">The first character of this paragraph will be 3em big
and in red color as defined in the CSS rule above. Rest of the
characters in this paragraph will remain normal. This example
shows how to use :first-letter pseudo element to give effect to
the first characters of any HTML element.</p>
</body>
</html>
我可以同时在“p”标签上同时使用这个伪元素首字母和首行,如下面的代码所示?
<p class="normal" "line"> First character of this paragraph will
be normal and will have font size 40 px;</p>
<p >The first character of this paragraph will be 3em big
and in red color as defined in the CSS rule above. Rest of the
characters in this paragraph will remain normal. This example
shows how to use :first-letter pseudo element to give effect to
the first characters of any HTML element.</p>