Sree Sankar
Comments are used to explain the code, and may help when you edit the source code at a later date. Comments are ignored by browsers. A CSS comment starts with /* and ends with */
Example:
/* This is a single-line comment */
p {
color: red;
}
In order to set the width and height of an element correctly in all browsers, you need to know how the box model works.
Important: When you set the width and height properties of an element with CSS, you just set the width and height of the content area. To calculate the full size of an element, you must also add padding, borders and margins.
The total width of an element should be calculated like this:
Total element width = width + left padding + right padding + left border +
right border + left margin + right margin
The total height of an element should be calculated like this:
Total element height = height + top padding + bottom padding + top border
+ bottom border + top margin + bottom margin
Let's see an Question
Calculate the total width of the below "element"?
div {
width: 320px;
padding: 10px;
border: 5px solid gray;
margin: 0;
}