Proposed Web Page Content Structure & Presentation Standard: General
Proposed Web Page Content Structure & Presentation Standard: General
General
XHTML Standard
CSS Standard
1. CSS styles should be placed in an external CSS file to promote the reuse and organization of styles
2. Use multiple CSS files, instead of one large CSS file (> ~30Kb), if you can organize the CSS styles by areas
of the site thereby avoiding download of unused styles (ie. adminSection.css, publicSection.css)
3. CSS files should be stored in the “css” folder in the root directory of the site/app or section
4. Images used in the presentation of the web page should be stored in the same folder (typically called
“images”) in the root directory of the site/app or section
5. External CSS files should be reference in the <head> section as follows:
<link rel="stylesheet" type="text/css" href="css/main.css" />
6. Reset styles with a reset.css to remove browser rendering differences. See Appendix A – reset.css
7. Do not use CSS hacks (See General Standard #7)
8. Use CSS classes where ever possible to promote style reuse/consolidation
9. Refrain from using element ids to avoid naming conflicts; use CSS classes instead
10. Use descendant selectors whenever possible to avoid verbose XHTML markup:
#navigation ul li { ... }
11. Avoid using absolute positioning without a relatively positioned parent, as it doesn’t promote free
flowing designs
12. Prefer to use multiple CSS classes on an element as opposed to using an id:
<div class="red smallText"></div>
13. Use CSS shorthand where possible/logical to shorten CSS length
margin: 0px;
padding: 0px 10px;
border-right: solid 1px #000;
14. Only use common fonts to ensure similar presentation across browsers/operating systems. Such as
Arial, Georgia, Verdana, etc.
15. Specify a general font-size as a percentage in the body style and use em units to specify font size for
child styles.
1. Heading Image Replacement - The text within heading tags can be hidden and replaced with an image,
within CSS, as follows:
HTML:
<h1>
<a href="">
<span class="text">Page Header 1</span>
<span class="image"></span>
</a>
</h1>
CSS:
h1
{
position: relative;
width: 123px;
height: 49px;
}
h1 span.text
{
display: none;
}
h1 span.image
{
position: absolute;
width: 100%;
height: 100%;
background-image: url("../images/logo.gif");
background-position: top left;
background-repeat: no-repeat;
}
2. Horizontal Navigation - Links can be placed in a list and styled to look like a menu
HTML:
<div id="navigation">
<ul>
<li>Home</li><li>Link 1</li><li>Link 2</li><li class="lastItem">Contact
Us</li>
</ul>
</div>
CSS:
#navigation ul
{
margin: 0px;
padding: 0px;
border: solid 1px #000;
width: 500px;
}
#navigation ul li
{
display: inline;
margin: 0px;
padding: 0px 10px;
list-style-type: none;
border-right: solid 1px #000;
}
#navigation ul li.lastItem
{
border: none;
}
3. Centering Content – You can center content across browsers by using the following styling
HTML:
<div class="parentToCenteredContent">
<div class="centeredContent">
<p>This paragraph should be centered.</p>
</div>
</div>
CSS:
.parentToCenteredContent
{
text-align: center;
}
.centeredContent
{
margin: 0px auto;
}
4. Columns – You can use the float property to create columns of content. Use display inline to avoid
double margins in IE.
HTML:
<div class="columnContainer">
<div class="contentColumn">
<h2>Column 1</h2>
<p>This is the content for column 1.</p>
</div>
<div class="contentColumn">
<h2>Column 2</h2>
<p>This is the content for column 2.</p>
</div>
<div class="contentColumn">
<h2>Column 3</h2>
<p>This is the content for column 3.</p>
</div>
</div>
CSS:
.columnContainer
{
position: relative;
width: 500px;
display: inline;
}
.contentColumn
{
width: 30%;
float: left;
display: inline;
}
5. Fixed Positioning in IE6 – You can use the “fixed” position in modern browsers but it doesn’t work in IE6.
This is a work around for the same styling.
position: absolute;
top: (145+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px');
right: expression(20+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');}
Appendix A – reset.css
http://www.evotech.net/blog/2008/05/browser-css-selector-support/