Separate Structure (HTML elements), Content (text, images, other
media), and Presentation (color, layout, etc.).
Important to note that while CSS allows good document structure, it does
not enforce good structure. -- DiveIntoMark
Easier to maintain and update a site
Can offer user a choice of style sheets to use (Mozilla, Opera. Not IE)
User can override author styles to better meet their needs
Things to Avoid
Using HTML structural mark up (h1, blockquote, etc.) for visual
effects.
for example using textarea instead
of iframe -
screen reader user thinks they are in a form.
Using HTML Presentational markup (font, center, etc.) to simulate
structural mark-up (i.e. lists, headings)
Using CSS styling to simulate proper structural mark-up
see ESPN.com
as example of mixing relative and fixed units. In IE turn on "ignore
font sizess" then scale the font sizes notice text overlapping,
etc. (This is a bug in IE. "Ignoring font sizes" does only that,
if line-height is fixed then the page breaks when scaling fonts.)
Always specify a fallback generic font.
Reveal acronyms and abbreviations to users (title will appear on screen
as a tool tip; screen reader can read title)
Item 1 (note: this example of a custom generated bullet only
works in Opera 6+ and Mozilla/Gecko based browsers, the bullet should look like » 'a double right angle')
@media print
a:after { content : " [" attr(href) "] " ;
}
(works in Mozilla/Gecko browsers and Opera; thanks to Aardvark.
This style sheet element requires no modifications or additions
to the HTML code)
@media screen {
.printonly {
display: none
}
}
@media print {
.printonly {
display: inline;
}
} This works in all 5.x+ browsers.
These style sheet elements require additional code
for all anchors (i.e. <span class="printonly">(http://www.admin.ox.ac.uk/)</span>University
of Oxford Central Administration(http://www.admin.ox.ac.uk/)
(Use print-preview feature of browser. Url of link should appear immediately
after the link.)
Remove unnecessary
stuff when printing. (Use
print-preview feature of browser. Notice that navigation bars, breadcrums,
footers, etc. have been removed from the print rendering of the page.)
Increase size of input form controls
Text input input {
font-size: 1em;
}
Radio buttons and checkboxes input {
height: 1em;
width: 1em;}
Change background-color of
input form controls
that have the focus.
input:focus {
background:#FFFF80;
color:black;}
Accessify (click
on or tab to an input field, notice color change of form control) Note:
this works in IE because of javascript.
Stylish Buttons (Using CSS to change the appearance of form buttons.)
Apply a "skin" to a list of links that makes them appear as a
block of images with JavaScript roll overs. Provide "rollover effect" from the keyboard. Rollovers can be created
for mouse users by using the :hover pseudo tag without the need
for scripting. The same styling that creates the rollover for the mouse can
be applied to create a keyboard "tab-over" by using the :focus (for
Gecko browsers) and :active (for IE) pseudo tags.
Dynamically outline elements with focus or hover. Outline declaration
draws outline (similar to border) around an element but does not take up
space (reflow the screen). The outline will overlap surrounding element if
necessary.
CSS Cautions
Generated content
- Current assistive technology relies on what the user's browser supports, that
is what can the browser display on the screen). If the browser does not support
a
CSS
rule,
the
user/AT
will
not "see" it.
pseudo-tags :before and :after when
used in conjunction with content.
the code in the previous list item should match the text below if the browser
supports the pseudo-tags with content < inserted content: text>code.example:before
{
content: <begin-code-example> }
code.example:after {
content: <end-code-example>
}<inserted content: graphic>
Note: IE 6 or before does not support these pseudo tags. if you use the "show stylesheet" tool, listed below,
on this page , you will see code.example:unknown instead
of code.example:before.
Resources
Books
Eric Meyer on CSS: Mastering the Language of Web
Design
by Eric A. Meyer
Publisher: New Riders Publishing; 1st edition (June 28, 2002)
ISBN: 073571245X
Sams Teach Yourself CSS in 24 Hours
by Kynn Bartlett
Publisher: Sams; 1st edition (July 10, 2002)
ISBN: 0672324091
Cascading Style Sheets 2.0 Programmer's Reference
by Eric A. Meyer
Publisher: McGraw-Hill Osborne Media; (March 20, 2001)
ISBN: 0072131780
Cascading Style Sheets: Designing for the Web (2nd
Edition)
by Hakön Wium Lie, Bert Bos, Robert Cailliau
Publisher: Addison-Wesley Pub Co; 2nd edition (July 13, 1999)
ISBN: 0201596253