An html div is a block-level element that defines a horizontal section of a webpage. A block level element has an embedded carriage return before and after the element. A <div> is similar to a paragraph <p> element, except that paragraph elements have a semantic meaning that they should be used to create blocks of text, while a div is a generic box that is commonly used for layout purposes.
In the code shown below, I've defined two paragraphs above two divs. Note that the default margin for paragraphs is the height of the font, while the default margin for the divs is zero.
The div element has few html attributes. The align attribute specifies the alignment of the content inside a div element. Possible values are; left, right, center, or justify. However, this attribute is deprecated and styles should be used instead.
Divs make heavy use of styles, so Without knowledge of CSS, you'll have have a difficult time with all but the most basic use of divs. Even with good knowledge of CSS, because box model styles are inconsistent between browsers and browser versions, you'll have a difficult time using divs for page layout. It requires many work-arounds to get them to display constantly.
However, using styles, a div can be given a specific width and height and changed to an inline box which makes it the best element to use for complex webpage layouts. Especially useful for webpage layout is the ability to nest divs as in the code shown below.
Another important styles concept to understand is that vertical margins collapse between adjacent elements. In other words, for adjacent vertical block-level elements, only the margin of the element with the largest margin value will be displayed. The margin of the element with the smaller margin value will be collapsed to zero. In order to become more skilled in the use of divs you should study the CSS box model.
Learn more at amazon.com