可以在没有段落标记的div中使用文本吗? [英] OK to have text in div without paragraph tag?

查看:129
本文介绍了可以在没有段落标记的div中使用文本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解< p> 标记的效用。我想写更少的HTML,并且总是为了简化一般事情,但感觉我听到有人提到为了SEO目的或清晰度或其他东西,所有文本都应该存在于段落标签中?它似乎只是需要处理一组保证金/填充/边境/ css业务。我不会通过某种linting工具吗?

I'm trying to understand the utility of the <p> tag. I want to write less HTML, and am always for simplifying things in general, but feel like I heard someone mentioning that for SEO purposes or clarity or something, all text should reside within a paragraph tag? It's just seems like one more set of margin/padding/border/css business to deal with. Will I not pass some kind of linting tool?

<div>
  Cheerio, worldie!
</div>

Vs:

<div>
  <p>Hello, world!</p>
</div>


推荐答案

是的,可以使用< div> 元素没有< p>

Yes, it is ok to use a <div> element without <p>.

A < p> 会告诉< div>内的文字元素被拆分为段落,因此如果您将文本拆分为段落,则应使用< p> ;另一方面, < p> 不能包含以下元素 - 称为短语内容;因此,您无法在< p> 中包含< div>

A <p> would tell that the text within a <div> element is split into paragraphs, thus if you have text split into paragraphs, you should use <p>; on the other hand, a <p> cannot contain elements other than so-called phrasing content; thus you cannot have a <div> inside a <p>.

这篇关于可以在没有段落标记的div中使用文本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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