CSS Development

Andrew J. Peterson

NDP Software

Overview

Introduction

Development Process

  1. Create plain XHTML: validating, semantic, minimal but not cryptic
  2. Prepare for Styling: Add Classes or IDs at highest level
  3. Style (Build interactive components too!)
  4. Test across browsers
  5. Now you're ready to build the actual JSP pages

Note: Often if the design changes it's worth going back to the HTML.

Basic Guidelines for HTML

Tables vs. Divs:
Q: Is it tabular data?
Divs vs. Spans:
Q: Block vs. inline
H1 vs. Divs and Spans:
Q: Does an HTML tag make sense?

Alternatives to DIVs

HTML You Might Not Know About

Preparing to Style

Naming IDs and Classes:
Use hyphens to separate words, all lowercase.
IDs vs. Classes:
Q: Can there be more than one per page?

Preparing to Style

Add classes and IDs at the highest level possible

Use an enclosing style or class when possible. For example:

<ul>
<li class="album">Let It Be</li>
<li class="album">Abbey Road</li>

</li>
is more concisely expressed as:
<ul  class="albums">
<li>Let It Be</li>
<li>Abbey Road</li>
</ul>
This may seem obvious, but quite common. There are more complex cases, that are harder to see. Basically, try to determine the meaningful outside element, and write selectors in terms of that.

Example

<div style="margin: 20px 10px 0pt;"> <h5>TeeBeeDee Founding Members</h5> <b>Interests</b><br>
<div style="margin: 0pt 0pt 10px; height: 55px; font-size: 14px;"> <div style="margin: 0pt 10px 0pt 0pt; float: left;"><a href="profile/Medelhart"><img src="/image/682.jpg..."></a></div> "Word puzzles baseball food exotic travel"<br>
<div style="float: left; font-size: 9pt; font-weight: bold;"><a href="profile/Medelhart">Medelhart</a></div>
<div style="height: 5px; clear: both;"></div> <b>Favorite Getaway</b><br>
<div style="margin: 0pt 0pt 10px; clear: both; height: 55px; font-size: 14px;"> <div style="margin: 0pt 10px 0pt 0pt; float: left;"><a href="/profile/ereith1"><img src="/image/1433.jpg..."></a></div> "Anywhere that isn't Central NY"<div style="float: left; font-size: 9pt; font-weight: bold;"><a href="/profile/ereith1">ereith1</a></div></div></div>
<div style="float: right; clear: both;"><a href="/browseFoundingMembers.html">View All Members �</a></div> </div>

Example: cleaned up

<div class="founding-members">
<h5>TeeBeeDee Founding Members</h5>
<h6>Interests</h6>
<a href="profile/Medelhart">
<img src="/image/682.jpg...">
</a>
<p>Word puzzles baseball food exotic travel
<a href="profile/Medelhart">Medelhart</a></p>
<h6>Favorite Getaway</h6>
<a href="/profile/ereith1">
<img src="/image/1433.jpg...">
</a>
<p>Anywhere that isn't Central NY<a href="/profile/ereith1">ereith1</a>
</p>
<a href="/browseFoundingMembers.html">View All Members �</a>
</div>

Styling: Writing CSS

Modularity

Font-sizing Strategy

TBD

TBD

TBD