Boxes help to separate blocks of content on web pages. This separation is accomplished using margin and border controls.
Here is CSS code that can be used to create a class for a box in the middle of a page with a bright red border:
Here is what happens when we invoke the class box_center. The box can include multiple paragraphs between the <div class = "box_center"></div> tags.
Create this box class on your style sheet and use it on an HTML page. Try experimenting with different amounts for the margin-right, margin-left, width, and padding. Observe what happens. We set the border style to solid. The default would be no border. Try that. Also, try other border styles, such as double and outset.
Sometimes, you want text to wrap around a box. It is important to set the width of the box to something well under 100%, so that there is room for the text to fill around it. Here is code for a floating box. Try it out and see what happens.
.boxright{
float: right;
padding: 2%;
width: 40%;
background: #33ffff;
border: thin solid blue;
margin: 1%;
}
Boxes are quite tricky. They require a lot of trial and error.