Wednesday, 3. February 2010
Padding can be applied to the outside edges of the content are of any block level or inline element. Padding creates the space between the edge of the element and its content.
Like margins, padding can be applied to individual sides of a box:
p {padding: 10px;}
h1{padding-top: 0px;}
h2{padding-right: 0px;}
h3{padding-left: 0px;}
h4{padding-bottom: 0px;}
Padding can also be applied using a single shorthand property. If one padding value is specified, it applies to all sieds of an element.
p {padding: 5px;}
If two values are specified, the top and bottom margines are set to the first value and the right and left margins are set to the second value.
p {padding: 5px 10px;}
If three values are specified, the top is set to the first value, the left and right to the second value and the bottom is set to the third value.
p {padding:5px 10px 0px}
If four values are specified, they apply to the top, right, bottom and left.
p {padding:5px 10px 3px 20px}
Posted in CSS Box Model by frenchsquared -
Friday, 22. January 2010
CSS 3.0 has a great new features called RGBa.
You can now make a transparent background, transparent text, or just about anything else transparent with RGBa.
.myClass {
background-color:rgba(255,255,255,0.5)
}
The above tag will color your area witha white background that is 50% transparent. The only issue with RGBa at this time is that IE doesnt support it. The only CSS 3.0 compliant browsers seem to be Firefox and Safri. However, I have tested this in Opera and it does work.
You can also change the color of text element with:
.myClass {
color:rgba(255,255,255,0.5)
}
The old style of transparency is still supported by all browsers
.transparent_class {
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}
The major difference between these two styles is that the new method RGBa will only effect the targeted ellement. Where as with opacity all subclasses are also affected.
Posted in Uncategorized by frenchsquared -
Wednesday, 16. December 2009
When designing a CSS based website it is very useful to understand Margins. I have found that it is much easier to deal with browser compatibility when one uses proper margin styles. Trying to set a top: -10px seems to cause browser issues that can be easily avoided by using margin-top:-10px.
Margins can be applied to the outside of any block level or inline element. They create space between the edge of an element and the edge of any adjacent elements.
Margins can be applied to the individual sides of an element.
p { margin-top: 0px}
p { margin-right: 5px}
h1 { margin-bottom: 3px}
h1 { margin-left: 4px}
Margins can also be used with a single short tag. If one value is set this value will be applied to all sides of the element.
p { margin: 5px}
If two values are set, the first value will be applied to the top and bottom of the element while the second value will be applied to the left and right margins.
p { margin: 10px 5px}
If three values are set the fist value is applied to the top, the second value is applied to the left and right and finally the third value is applied to the bottom.
p { margin: 10px 5px 7px}
If for values are set the first value is applied to the top, the second value is applied to the right, the third value is applied to the bottom and the forth is applied to the left.
Top, Right, Bottom, Left
p { margin:10px 5px 7px 3px}
Posted in CSS Box Model by frenchsquared -
Saturday, 3. October 2009
The content are of a box can be given width, height, and color. Width and height can be specified in points (equal to 1/72 of an inch), picas (equal to 12 points), pixels, ems, exes, millimeters, centimeters, inches, or percents.
p { width: 100pt ;}
p { width: 20pc;}
p { width: 300px;}
p { width: 40em;}
p { width: 50ex;}
p { width: 600mm;}
p { width: 8in;}
p { width: 50%;}
The color property can be used to style the text color. Color can be specified in a number of ways, including keywords, hexadecimal, and RGB.
Keywords for color included: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow. Although some other words may work in some browsers, they are not part of the specification and should not be used.
Hexadecimal colors can be specified using only three or six hexadecimal characters. When a color has three pairs of hexadecimal digits (such as #ff0000), it can be shortened by removing one digit from each pair (#f00). RGB colors can be specified using three comma-separated integers or percent values. For example, the color red can be specified using either rgb(255, 0, 0) or rgb(100%, 0%, 0%).
p {color: red }
p {color: #f00 }
p {color: #ff000}
p {color: rgb(255,0,0)}
p {color: rgb(100%, 0%, 0%)}
Posted in CSS Box Model by frenchsquared -
Wednesday, 26. August 2009
The border properties specify the width, color and style of the border of an element. Shorthand border properties include border-top, border-bottom, border-right, border-left and border.
p {
border-top:
1px solid red}
p {
border-right:
2px solid blue}
p {
border-bottom:
1px solid red}
p {
border-top:
2px solid black}
h1 {border: 1px solid black}
Posted in CSS Box Model by frenchsquared -
Monday, 24. August 2009
Padding can be applied to the outside edges of the content area of any block level or inline element. Padding creates the space between the edge of the element and its content.
Like margins, padding can be applied to individual sides of a box.
p {padding: 10px}
h1 {padding-top:0px}
h2 {padding-right:5px}
h2 {padding-bottom:7px}
h3 {padding-left:10px}
Padding can alse be applied using a single shorthand property. If one padding value is specified, it applies to all sides of an element:
p {padding:5px}
If two values are specified, the top and bottom margins are set to the first value and the right margins are set to the second:
p {padding: 5px 0}
If three values are specified, the top is set to the first value, the left and right are set to the second, and the bottom is set to the third:
p {padding: 10px 0 20px}
If four values are specified, they apply to the top, right, bottom, and left:
p {padding 5px 0px 7px 15px}
Posted in CSS Block Quote by frenchsquared -
Sunday, 23. August 2009
The background-color property sets the background color of an element.
The backgound-image property applies a background image to an element, which will appear on top of any background-color.
body {
background-color:#000
}
h1 {
background-image:url(header.png);
}
Posted in CSS Adding Background Images by frenchsquared -
Wednesday, 19. August 2009
Margins can be applied to the outside of any block level or inline element. They create space between the edge of an element and the edge of any adjacent elements.
Margins can be applied to individual sides of a box:
p { margin-top: 0;}
p { margin-right: -5px;}
p { margin-bottom: 10px;}
p { margin-left: 5px;}
Margins can also be applied using a single shorthand property. If one margin value is specified, it is applied to all sides of an element:
p { margin: 5px;}
If two values are specified, the top and bottom margins are set to the first value and the right and left margins are set to the second.
p { margin: 5px 10px;}
If three values are specified, the top is set to the first value, the left and right ar set to the second, and the botton is set to the third.
p { margin: 5px 10px 3px;}
If four values are specified, they apply to the top, right, bottom, and left.
p { margin: 5px 6px 7px 8px;}
It should be noted that you can use negative values for the margin. This can cause the element to overlap another element.
Posted in CSS Box Model by frenchsquared -
Saturday, 15. August 2009
Setting the Box Width
The width of an element is applied to the content area. Other measurements such as padding, border and margins are added to this width.
For example, if an element is specified with width: 200px; the content area is 200px wide. If padding, boder, or margin are applied to the same element, their measurements are added to the overall width.
However, this method does not applie to IE 5 or 6, but who really cares. Anyone using IE 6 needs to upgrade.

Posted in CSS Box Model by frenchsquared -
Friday, 14. August 2009
Block level elements are normally displayed as blocks with line breaks before and after. Examples of block level elements include paragraphs, headings, divs and block quotes.
Inline elements are not displayed as blocks. The content is displayed in lines and there are no line breaks before and after. Examples of inline elements include emphasized text, strong text, and links.
All block level and inline elements are boxes that use the box model. Both types of elements can be styled with box model properties such as margin, background-color, padding, and border.
Some box model properties, such as height and width, do not apply to inline elements. Also, margin and padding applied to an inline element will affect the content on either side, but not the content above or below.
My next few posts will cover this concept in more detail…
Posted in CSS Box Model by frenchsquared -