Image Help: Lines & Rules
- Introduction
- Lines & Rules
- Bullets
- Characters
- Nav & Info
- Color Coding
These are graphical lines that give parts of a page a visual separation, otherwise known as horizontal rules.
Sampling of Image Rules
Advanced CSS Technique
Instead of simply putting an image in your page to serve as replacement for an HTML horizontal hule, try using an advanced CSS technique. By following the example below you will still be providing the proper HTML context while displaying the rule graphically.
|
<style type="text/css" media="screen, projection"><!-- div.hr{ text-align: center; } div.hr div{ background-image: url('/PATH_TO_IMAGE/IMAGE_NAME'); background-repeat: none; background-position: center; width: WIDTHpx; height: HEIGHTpx; margin: auto; } hr{ display: none; } --></style> |
Remember to replace the necessary code pieces for your image rule.
- /PATH_TO_IMAGE/IMAGE_NAME is to be replaced with the web path and image name to your image.
- WIDTH should be set to the pixel with of the image.
- HEIGHT should be set to the pixel hwight of the image.
Notice also that this CSS code is defined only for the media: screen, and projection. This is important as you only want to use the graphic on the visible screen. Other media types like print, Braile, teletype, and others should recieve the standard HTML rule.
|
@media screen, projection{ ... place CSS definitions here ... } |
| <div class="hr"><div><hr></div></div> |
|
|
What's the benefit?
You might think it a waste of effort to code the rule in this maner, after all, the result looks the same. The difference is that when CSS is not supported the HTML rule is then displayed. This is very much preferred over the absense of the desired separation. Small screen devices most often do not support CSS and this method will still provide the desired content separation.
Another benefit to using this approach is that you can now change all the horizontal rule images throughout your site from your style sheet. Imagine changing dozens or hundreds of rules in a large site by changing a few lines of CSS code.
