首页 > 解决方案 > 在标记小说时,我应该使用多个 p 元素还是一个带有 br 元素的 p 元素?

问题描述

我想知道我正在做的是否是“正确的方法”,即使在编程中(认为 HTML 并不是真正的编程语言)有几种方法可以解决问题。

我目前正在通过制作一个用户可以在其中阅读小说/书籍的网站来应用我目前对 HTML 的了解。我想知道是否应该为每个段落使用多个 p 元素,还是应该为具有多个 br 元素的单个段落使用。

我目前正在使用多个 p 元素。所以我怀疑这是否是正确的方法。有时书中有些段落只占用在线,通常是在与字符进行对话时,所以我的 html 文件中有很多 p 元素。

<p>
    Look, I didn't want to be a half-blood.    
</p>
<p>
    If you're reading this because you think you might be one, my advice 
is: close this book right now. Believe whatever lie your mom or dad told you about your birth, and try to lead a normal life.
</p>
<p>
    Being a half-blood is dangerous. It's scary. Most of the time, it gets you killed in paiful, nasty ways.
</p>
<p>
    If you're a normal kid, reading this because you think it's fiction, great. Read on. I envy you for being able to believe that none of this ever happened.
</p>
<p>
    But if you recognize yourself in thses pages&mdash;if you feel something stirring inside&mdash;stop reading immediately. You might be one of us. And once you know that, it's only a matter of time before <em>they</em> sense it too, and they'll come for you.
</p>
<p>
    Don't say I didn't warn you.
</p>
<hr>
<p>
    My name is Percy Jackson.
</p>
<p>
    I'm twelve years old. Until a few months ago, I was a boarding student at Yancy Academy, a private school for troubled kids in upstate New York.
</p>
<p>
    Am I a troubled kid?
</p>
<p>
    Yeah. You could say that.
</p>
<p>
    I could start at any point in my short miserable life to prove it, but things really started going bad last May, when our sixth-grade class took a field trip to Manhattan&mdash;twenty-eight mental-case kids and two teachers on a yellow school bus, heading to the Metropolitan Museum of Art to look at ancient Greek and Roman stuff.
</p>
<p>
    I know&mdash;it sounds like torture. Most Yancy field trips were.
</p>
<p>
    But Mr. Brunner, our Latin teacher, was leading this trip, so I had hopes
</p>

所以结果看起来和书中的一样。但我唯一想知道的是,是否只使用单个 p 元素然后使用不同的 br 元素会更好。

标签: html

解决方案


标签用于段落,<p>所以如果它们真的是段落(并不总是很容易说),它们都应该用自己的<p>标签包装。<br>如果您知道我的意思,我喜欢考虑更像是 shift+enter...如果您需要我的建议,请坚持当前的方法,并且<br>仅在非常明显时才使用。


推荐阅读