CSS Pro CSS Training CSS Code CSS Margins CSS Help News
 

CSS Margins

Using CSS (Cascading Style Sheets) has become a popular way to simplify the programming of many style elements, such as color, font, alignment, tables, spacing, and margins. CSS margins refers to the spacing that is around webpage elements, at the top, bottom, and sides of pages and how that spacing is used to apply properties to the borders of any HTML document. Previously, HTML code required repetitive entry of code elements and resulted in more complicated page programming.

Each of the CSS margins can be changed independently, allowing the page to be fully customized with different layouts. Values are used to describe the margins, and are typically written as "margin-top," "margin-right," "margin-bottom," or "margin-left." Values are assigned to the CSS margins either as one value that applies to each margin, or individually as percentages. For example, CSS margins code may look like, "

" and this will result in a document having a border of 20 pixels on each side. By changing the "20," the length, width, or height of the margin is adjusted.



Changing the border is not difficult, and each side of the document can have its own properties, the CSS margins would just be coded to incorporate those instructions.