DIV和BR的区别

huangapple go评论101阅读模式
英文:

Difference between DIV and BR

问题

尝试理解<div></div><br>之间的基本区别。我明白它们都可以用来分隔内容,但我应该如何知道在何时使用哪一个?此外,div的主要目的是为了让代码更易阅读吗?它是用来将内容分组的吗?

我尝试输入两个独立的段落,一个使用div,另一个使用br,以查看它们在网页上的显示效果。结果是相同的。

英文:

Trying to understand the fundamental difference between <div></div> and <br>. I understand that they both can break up content, but how do I know which one to use and when? Also, is div's main purpose to make reading code easier? Like it groups things together?

I tried typing out two separate paragraphs, one using div and one using br, to see how it would look on a webpage. Outcome was the same.

答案1

得分: 1

div 标签和 br 标签具有不同的目的并且在不同的上下文中使用。

div 标签用于将相关的 HTML 元素分组在一起并创建一个块级容器。div 标签的主要目的是帮助结构化和组织您的内容。

另一方面,br 标签用于在文本段落内插入换行或新行。它不会将元素分组在一起或创建容器。

关于何时使用每个标签,这实际取决于您想要实现什么效果。如果您想要将相关元素分组在一起并为它们创建一个容器,那么您会使用 div。如果您想要在文本行之间添加间距,那么您会使用 br

英文:

The div and br tags have different purposes and are used in different contexts.

The div tag is used to group together related HTML elements and create a block-level container. The main purpose of the div tag is to help structure and organize your content.

On the other hand, the br tag is used to insert a line break or a newline within a paragraph of text. It does not group elements together or create a container.

In terms of when to use each tag, it really depends on what you're trying to achieve. If you want to group together related elements and create a container for them, then you would use div. If you want to add spacing between lines of text, then you would use br.

答案2

得分: -2

"Using DIV will allow you to specify what the section break is using CSS. You can also easily control any formatting within that section using styling. A BR is just a line break in the text; it doesn't have any inherent meaning. The BR cannot be styled."

英文:

"Using DIV will allow you to specify what the section break is using CSS. You can also easily control any formatting within that section using styling. A BR is just a line break in the text it doesn't have any inherent meaning. The BR cannot be styled."

Source:https://youtu.be/jTS9JDe20mg

答案3

得分: -2

The div tag is a block element and br tag is an inline element.
Div标签是一个块级元素,br标签是一个内联元素。

Div tag will create a group of elements.
Div标签将创建一组元素。

BR tag will create a line break.
BR标签将创建一个换行。

英文:

The div tag is a block element and br tag is an inline element.

Div tag will create a group of elements.
BR tag will create a line break.

huangapple
  • 本文由 发表于 2023年5月7日 19:16:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76193587.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定