我应该使用 <p/>在标记中标记? [英] Should I use the <p /> tag in markup?

查看:23
本文介绍了我应该使用 <p/>在标记中标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当需要更高级的东西时,我总是使用 <br/><div/> 标签.

是否仍然鼓励使用 <p/> 标签?

解决方案

现代 HTML 语义是:

  • 使用 <p></p> 在文档中包含一段文本.
  • 使用<br/> 表示段落内的换行符(即没有段落块边距或填充的新行).
  • 使用 <div></div> 来包含一块恰好具有块布局的应用程序 UI.

不要单独使用

,这些标签旨在包含内容.它们似乎作为分段符起作用,只是因为当浏览器看到它们时,它有帮助地"关闭当前块标记,然后再打开空标记.

I have always used either <br /> or a <div/> tag when something more advanced is necessary.

Is use of the <p/> tag still encouraged?

解决方案

Modern HTML semantics are:

  • Use <p></p> to contain a paragraph of text in a document.
  • Use <br /> to indicate a line break inside a paragraph (i.e. a new line without the paragraph block margins or padding).
  • Use <div></div> to contain a piece of application UI that happens to have block layout.

Don't use <div /> or <p /> on its own, those tags are meant to contain content. They appear to work as paragraph breaks only because when the browser sees them, it "helpfully" closes the current block tag before opening the empty one.

这篇关于我应该使用 &lt;p/&gt;在标记中标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆