(All examples, unless otherwise noted, are contained within a white box with shaded sides)
From the World Wide Web Consortium:
The <border-style> value type, which may take one of the following values:
- none
- No border; the computed border width is zero.
- hidden
- Same as 'none', except in terms of border conflict resolution for table elements.
- dotted
- The border is a series of dots.
- dashed
- The border is a series of short line segments.
- solid
- The border is a single line segment.
- double
- The border is two solid lines. The sum of the two lines and the space between them equals the value of 'border-width'.
- groove
- The border looks as though it were carved into the canvas.
- ridge
- The opposite of 'groove': the border looks as though it were coming out of the canvas.
- inset
- The border makes the box look as though it were embedded in the canvas.
- outset
- The opposite of 'inset': the border makes the box look as though it were coming out of the canvas.
Playing with these we get the following (all are padded-out 5pt to make them a bit more readable with a 1-em margin below):
The following style is used:
.margin {
color: red ;
margin-top: 2em ;
margin-right: 3em ;
margin-bottom: 2em ;
margin-left: 3em ; }| x xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx x |
x xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx x |
Note that assigning the class to the <td> element has no effect, but assigning the class within the <td> element via (in this example) a <div> element produces the anticipated effect.
The following style is used:
.padding {
color: red ;
padding-top: 2em ;
padding-right: 3em ;
padding-bottom: 2em ;
padding-left: 3em ; }| x xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx x |
x xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx x |
Note that assigning the class to the <td> element or within the <td> element via (in this example) a <div> element both produce the anticipated effect (although note the slight differences in the rows if the browser window's width is slightly adjusted).
The following style is used:
.border {
color: red ;
border-color: #ccffff ;
border-width: 2em ;
border-style: double }| x xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx x |
x xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx x |
Note that assigning the class to the <td> element or within the <td> element via (in this example) a <div> element both produce the anticipated effect.
The traditional way of controlling the position, shading, and size of horizontal rules has been to do something like this:
<hr align="left" width="5" size="5px" noshade="noshade" />
Which would produce this:
In the strict modes of html 4.1 and xhtml 1.0 and in xhtml 1.1, none of those attributes exist, so all control of the horizontal rule must be accomplished by use of CSS. This is not altogether intutive, but once the techniques are identified it is farily easy. For the above example, the following code was used:
<div style="
margin-top: 1em ;
margin-left: 0 ;
margin-right:75% ;
background: #808080 ;
color: #808080 ;
border-top: solid 5px "></div>The horizontal rule may be created by either a <div> element or a <hr /> element, so this also works:
<hr style="
margin-top:1em ;
margin-left:0 ;
margin-right:75% ;
background: #808080 ;
color: #808080 ;
border: 1px solid ;
height:5px " />In the above examples, there are some duplication of controls to account for differences in how Netscape/Mozilla and Internet Explorer draw the line.
The prevailing philosophy at W3C is to move away from using specialized markup to draw the page but instead use the containing elements of the content to format the rendering. Thus, instead of of the following code fragment . . .
<hr /> <p>Some irrelevant confabulations here.</p>
which would be rendered thus:
Some irrelevant confabulation here.
the following would be recommended:
<p style="
margin : 0.5em 0 1em ; /* space the paragraph with respect to page and surrounding content */
border-top-color : #cccccc ;
border-top-style : groove ; /* format horizontal rule */
border-top-width : 3px ;
padding-top : 1em /* position paragraph content with repect to horizontal rule */
">
Some other irrelevant confabulation here.</p>which would be rendered thus:
Some other irrelevant confabulation here.
That notwithstanding, legacy pages are full of <hr /> elements, and it may be easier for developers to modify them to conform to html/xhtml strict standards than to replace them outright. That stated, here are some more examples using the <hr... format:
<hr
style="
height: 3px;
border-color: #888;
border-style :inset ;
border-width: 1px " />This is pretty much the default <hr />, which simply entered as <hr /> looks like this:
With adjustment of the margins it may be moved across the page, with more control than simply left/center/right:
<hr
style="
margin: 0px 2% " />
<hr
style="
margin: 0px 25% " />
<hr
style="
margin: 0px 25em 0px 10% " />
<hr
style="
margin: 0px 10% 0px 55% " /> A thin, unshaded line:
<hr style="
margin: 0 auto 0 ; width: 100% ; height: 1px ;
color : #333333 ;
shade : noshade ;
background-color : #ffffcc ;
border-top : 1px solid ;
border-bottom : 1px solid " />A thicker, unshaded line:
<hr
style="
color: #666;
background-color: #666;
height: 3px;
border: none " />A few additional examples:
<hr
style="
color : #fff ;
height: 5px ;
border: 2px inset #000 " />
<hr
style="
margin: 0 auto 0 ;
width: 30% ;
height: 3px " />
<hr
style="
margin: 0 auto 0;
width: 10% ;
height: 3px ;
background : gray ;
border-top : gray 1px solid ;
border-bottom : gray 1px solid " />
<style type="text/css">
.margin {
color: red ;
margin-top: 2em ;
margin-right: 3em ;
margin-bottom: 2em ;
margin-left: 3em ; }
.padding {
color: red ;
padding-top: 2em ;
padding-right: 3em ;
padding-bottom: 2em ;
padding-left: 3em ; }
</style>
The background style of the various areas of a box are determined as follows:
Thus,
<style type="text/css">
body {
background-color: white }
td {
background-color: #ffffff }
</style>
produces backgrounds of white in general, but yellow in table data cells ( ) .
<style type="text/css">
.padding_background_demo {
font-weight: bold ;
font-size: 20px ;
color: blue ;
background: #ccffcc ;
padding: 1em 5em }
</style>
|
Document: http://
Revised: |
[ TOP ] [ HOME ] |
Copyright © 2004 - 2010
Steve Sconfienza, Ph.D.
All Rights Reserved