AdBlock Detected!
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.
CSS Margin |
As we saw from the box model, margin is the space outside of the border, and is used to determine spacing among the different elements. In a box, there are four sides. So, we can specify margins up to the 4 sides: A fifth property, margin, is used as a shortcut for the above four properties. Margins can be specified in 3 ways: length, percentage, or auto. Let's take a look at an example:
The following HTML
renders the following:
Notice the margin between the box and the top, left, and bottom of the light green area are 5px, 10%, and 20px, respectively. Margin shortcutsAll four margins can be specified on a single line using the margin property. The syntax is as follows: margin: [margin-top] [margin-right] [margin-bottom] [margin-left] The order is very important here. The first element is always the top margin, the second is always the right margin, the third is always the bottom margin, and the fourth is always the left margin. |
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.