简体   繁体   English

使用CSS3单独格式化段落

[英]Formatting Paragraphs Separately using CSS3

Using CSS3, I can format a single paragraph <p> validly. 使用CSS3,我可以有效地格式化单个段落<p> But when I need multiple paragraphs with different formatting, I rename my paragraphs to <p1> and <p2> . 但是当我需要具有不同格式的多个段落时,我将我的段落重命名为<p1><p2> I can format them individually, but it does not pass the validity test. 我可以单独格式化它们,但它没有通过有效性测试。 How can I do this in a manner where it will still be valid? 我怎么能以它仍然有效的方式做到这一点?

The way I am currently doing it gives me the following errors: 我目前正在做的方式给了我以下错误:

Element p1 not allowed as child of element body in this context.
Element p2 not allowed as child of element body in this context.

Don't change the element's tag name. 请勿更改元素的标记名称。

Add a class or an id to the element in order to differentiate between them. 向元素添加classid以区分它们。

<p class="p1">Paragraph 1</p>

<p class="p2">Paragraph 2</p>

jsFiddle example jsFiddle例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM