Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Build a Simple Website Text Editors and HTML Creating Structure

Dotoria Corny
Dotoria Corny
1,867 Points

<div> and <p>

I noticed that when we use div tag, the result on the browser is on the new paragraph, but I don't know whether it's because of div tag itself or there is other reasons behind this.

I understand paragraph tag quite well, but still not clear about div that much.

Thus, I wonder, do those 2 tags make the new paragraph?

3 Answers

cecil merrell
cecil merrell
6,873 Points

The div tag defines a division or a section in an HTML document.

The div tag is also used to group block-elements to format them with CSS.

for example :

<div style="color:#FFF" class="whatEverYourCSSclassNameIsForStyling">
  <h3>This is your Heading</h3>
  <p>This is your paragraph.</p>
</div>

Most web browser translate the div tag automatically as a block section with the css below

div {
    display: block;
}
Dotoria Corny
Dotoria Corny
1,867 Points

And..is that the reason to make the new section or paragraph showing on the browser?

cecil merrell
cecil merrell
6,873 Points

yes, your browser is automatically applying the CSS and styling the div into a block.

If I remember correctly you can use normalize.css and then your own custom .css file to change how the browser views these div tags

Boy Buijsman
Boy Buijsman
13,773 Points

The <div> tag gets standard styling from the CSS thus giving it margin and padding.