Streaming live at 10am (PST)

When to use a DIV block?


#1

Under what circumstances would you put content in a DIV block as opposed to dropping and positioning it inside a container? Thanks in advance for your help!


#2

Div means Division of page. Containers are divs with special properties. Sections too. Div is the basic bow element in HTML. In HTML5, there are more tags to define them than before. (select a div and look Tag in the Settings tab)

Use a div whenever you need to create a division. Use them to share properties. You could decide to create a "card" with two text elements, a title and a paragraph, giving them not only their font properties but also paddings, backgrounds, borders... but you can also achieve the same result by creating a div for the card, then two divs for the header and content, then place inside a H title and a paragraph. Visually it will be the same but the properties aren't shared the same way.

Putting things into other things is called Nesting in CSS. It's not a bad practice, sometimes it's even recommended.

http://www.html-5-tutorial.com/div-tag.htm


#3