With margins, you can control the white space around an area. That area could be an image, a table, or even the body.
Margins are measured in lengths, or percentages.
If I wanted one (just one!) image in my document to have 20px of white space all around the edges, I would set up my CSS like this:
Then, I would set the class attribute in the image tag to "spec". Example; <img src="image.gif" class="spec" />. If I wanted all the images to have 20 pixels of white space, I could take out the .spec part in the CSS.
But, what if you wanted the top margin to be 10px, the bottom margin to be 40px, the left to be 90, and the right to be 20? Then you could type:
The padding of an item is similar to margins, except padding effects how much the content of the item pushes in wards. It is the amount of space between the borders of the item, and the content within.
Padding is set up the same way margins are, only your replace "margin" with "padding". For example, I could set the padding on the left and right sides of the contents of a <td> tag with this:
Borders can be placed around pretty much anything. You can place a border around an image, a body of text, or even a table. You can use CSS to specify the width, color, and even decoration of the border. You can also specify t o only put a border on the top of an element, or on whichever side(s) you want.
The border-style property can be set to: dotted, dashed, solid, double, groove, ridge, inset, or outset. If you wanted a table to have a blue, dotted border you would type:
You need to always specify a border style.
The border-color property can be set to whichever color you like. It can be a hex value, a name, or an RGB value.
All content enclosed in the <font> and </font> tags will have a border colored #990000.
You can specify the width of a border like this:
Or, you could specify the width of each individual border:
You can also be specific about what sides have borders, and what sides do not. If you only want a right border, and a top border with a solid, 2px, #99000 border you could type:
border-top: solid #990000 1px;
border-right: solid #990000 1px;
Note that it is possible to string redundant pieces of information together like above. You could also type that like this:
When you set the float property to an element, text can flow freely around it. Float can have a value of right, or left, which places the element on the right or left of the screen, allowing text to flow freely around it.
Here is how you could set the float attribute to all your image tags:
If you only wanted a certain section of information to flow around an object, and another section to format as normal, you could use the clear property. This property can be set to left, right, both, or none.
For example, let's say I had a CSS document that looked like this:
All the text could flow around the image, but if you wanted a certain section not to, you could just place <br class="left">, and text that comes after that will be under the image.
Clear can more or less be used to override float, and is best set to headers.
When you use the display property, you can determine how a tag is treated. The values are; block, inline, none, and list-item (list item only works on Netscape 4, or IE 5 for Mac).
block makes a tag have a line break after it, like the <p> tag.
inline makes a tag have no line break, like the <i> tag.
none Content enclosed will not even display. Great for hideing information that you do not want the browser to ignore, like counters.
list-item places list-item marker on the first line of text.
For example, let's say I wanted all my <b> tags to make a line break, but I wanted all my <p> not to, I'd type: