skip to Main Content

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.

3

Answers


  1. Chosen as BEST ANSWER

    "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


  2. 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.

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search