Dreamweaver II | Advanced CSS Formatting


Course Developer: Piper Nilsson
Instructor: Piper Nilsson
Graphics: Piper Nilsson, Tara MacKay; Layout: Patricio Sarzosa
Editors: Tara MacKay, Rachel Sokol


Piper Nilsson
Hello and welcome to Dreamweaver II! In this course, you'll have a lot of fun exploring Dreamweaver's flexible layout tools and interactive features. You'll also build some Dreamweaver project management skills that can take you to the next level professionally. Enjoy!

Advanced CSS Formatting

In this lesson, we'll make a retro-themed site with cutting-edge CSS technology.

Convenience, flexibility, and a streamlined workflow make CSS (Cascading Style Sheets) an essential tool in any Web design project.

You're probably familiar with basic CSS text formatting. In this lesson, you'll find that there is so much more you can do with CSS to improve your visual design concepts and speed up site development. We'll focus on advanced text formatting features and introduce new options for styling tables, page bodies, and other content areas with CSS. Emphasis will be placed on making good design decisions, not just the right technical moves.

Downloads: Files for use throughout the course are available in the course download area. Please be sure to download the files for the version of the program you are using (8 or CS3) where two options are given.

In this lesson, you can expect to:

Get a refresher on basic CSS type formatting.
Learn advanced CSS text features and typography design tips.
Learn to use CSS to format layout tables and data tables.
Learn how lists, the page body, and other content areas are formatted with CSS.
Explore CSS compatibility issues and tips.

 

 

 

 

 

In December 2005, Macromedia was acquired by Adobe. The most recent version of the program is called Adobe Dreamweaver CS3. This course covers Adobe Dreamweaver CS3 and Macromedia Dreamweaver 8.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Make quick changes to your rules directly in the CSS Styles panel, or make larger changes in the CSS Rule Definition dialog.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

An internal style might be useful for a special bit of formatting that is only needed on a single page.

 

 

 

 

 

 

 

 

 

 

 

 

 

Choosing the tag radio button creates a type selector. Type selectors are used to select a certain type of html tag, for example, paragraph tags or table tags.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If your type selector doesn't apply to your HTML page, the tag may not be in use. Check Code View to make sure.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

To format a page title with the <h1> tag, select the text, then choose "Heading 1" from the Format menu in the Properties Inspector.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Generous line height improves readability—the extra space between the lines of text will guide the reader's eye across the page.

 

 

 

 

 

 

 

 

 

 

 

 

If your style doesn't appear properly within Dreamweaver, check in various browsers for compatibility.

 

 

Type Formatting Refresher

 

At this stage in your Dreamweaver and Web design career, you should only be using Cascading Style Sheets (CSS) to format your site text (except graphic text, of course). This is the default in Dreamweaver CS3 and Dreamweaver 8, preventing the use of HTML <font> tags for formatting. You can change your Dreamweaver preferences to format text with font tags, but there is no good reason to do so. Besides, it is highly discouraged by the World Wide Web Consortium.

Shops, blogs, information hubs... Sites of all types and audiences use CSS to make their typography unique and appealing.

So, why all this fuss about CSS text formatting? It's all about the options. With CSS, you have greater control over font sizes, line spacing, padding, link styles, and lots more.

In addition, CSS helps you maintain consistent formatting across an entire Web site. You can change that formatting with just a few keystrokes. This will save lots of time if your client decides that he or she likes Times New Roman way better than Arial at the last minute.

You already know the basics, so we'll explore some advanced features after this quick refresher.

CSS Styles Panel

The CSS Styles panel is Dreamweaver's home for all of your type styling needs. Click the New CSS Rule button to start creating styles. This will bring up the New CSS Rule dialog where you can choose a selector type and decide where the style will live (inside or outside your Web page).

The New CSS Rule dialog (left) and CSS Styles panel (right).

Clicking OK will bring you to the familiar CSS Rule Definition dialog where you get to go wild, choosing font size, color, weight, and other properties.

I've defined a few font properties in the Type category of the CSS Rule Definition dialog.

If you need to edit a CSS rule, just look to the CSS Styles panel. You can edit or add properties directly in the Properties pane, or double-click the rule name under All Rules to bring back the full CSS Rule Definition dialog.

The Properties pane of the CSS Styles panel gives you quick access to rules so you can make changes on the fly.

External Style Sheets

Throughout this course, we'll mostly work with external style sheets. You'll recall from your previous Dreamweaver experience that an external style sheet is a document with a .css file extension that "links" to your HTML files. This allows you to apply the same styles to as many pages as you like.

Creating an external style sheet is easy—let's make one now. First, download the vintage folder to your hard drive from the course download area. We'll work on this vintage-themed Web site throughout the lesson, using this folder as its home. Define a new site (Site > New Site) and select the vintage folder as the local root folder.

Open the vintage.html file. You'll see that the page contains a table, a banner graphic, and a list of links—but no formatting.

Without formatting, there is no cohesive style or punch to make you want to read the text.

Now we'll start out, as many designers would, by defining the main paragraph style for the site. Click the New CSS Rule button in your CSS Styles panel.

Select the Tag radio button and enter the letter p in the Tag field (or choose it from the dropdown menu). This will define the style of all paragraphs (text within the <p> tag).

Choose New Style Sheet File from the Define In dropdown menu. Click OK. Name your new CSS file vintagestyle.css and save it in your vintage folder.

Defining your first style in a "New Style Sheet File" will automatically create your external .css file and link it to the html file.

The CSS Rule Definition dialog opens up next. For now, let's give this rule some simple properties in the Type category: Arial, Helvetica, sans-serif for the font family, black for the color, and 12 pixels for the size. Click OK to finish up.

We gave our paragraph text some basic properties.

Type Selectors

You just created a type selector, meaning that your rule will select a certain type of html tag—the <p> tag.

If you look at the HTML code for this page in Code view, you'll see that the text paragraphs are set within <p> tags. In Design view, these paragraphs display in a 12 pixel black Arial font, as specified. The other text, not set within <p> tags, has been left alone.

Only the paragraphs set within <p> tags are affected by our new rule. The other text will need some more work later.

Type selectors are great for formatting large content areas, but sometimes, you will want to style just one paragraph, or even just a few words in a paragraph. For this purpose, you'll use a class selector. Let's make one now.

Class Selectors

Click the New CSS Rule button, and this time, choose the Class selector type. Give your class a name: specialtext. Make sure this style is defined in your external style sheet, vintagestyle.css.

By default, any additional styles you create will be saved in your existing external style sheet. But always check, just in case.

Now select some properties. Don't do anything to the font family or size—we'll leave this blank so the <p> style handles them. But let's override the Color with a dark aqua (#006666) and change the Weight to bold.

Since the specialtext style will only be used on words within paragraphs, we don't need to define the font family or size. We already did that with the redefined <p> tag.

The new specialtext style can be applied anywhere we like using the Style dropdown menu in the Properties Inspector. Go ahead and apply it to the first sentence of each paragraph.

Class styles are found in the Style menu of the Properties Inspector. Just select the text you want to change, choose your style, and you're all set.

Advanced CSS Typography

Font, size, color... it's all so flexible in CSS, but there is so much more to typography than this. We're going to take CSS to the next level, exploring the settings for cases, weight, and spacing. These features not only make your type look terrific, but they also improve the readability of your content.

Cases and Weights

Closer inspection of the CSS Rule Definition dialog will uncover options for small-caps (where lowercase letters are just smaller versions of capital letters), capitalize (where the first letter in every word is capitalized), uppercase, and lowercase.

These treatments can be used to add emphasis to an important text area.

These features are useful for maintaining consistency across a site, especially when working with a team. It can be hard to get everyone to remember whether or not to capitalize certain headers and other information. Plus, special case treatments can give important areas of text the visual emphasis they need. Let's add a capitalized header to our vintage design.

The first sentence on the page is set with the <h1> tag, and the second is set with the <h2> tag. We'll create type selectors for both of these tags.

If you're not sure what tags are formatting an area of text, just jump into Code View. Here we see the tags for our two headers.

Let's start with the <h1> tag. Create a new rule. Choose the Tag radio button and h1 from from the Tag menu.

Choose a font family you think suits the page (I like Arial, which we used for the <p> tag as well), and pick a font color and size. Then choose uppercase from the Case menu. Click Apply to see if you like your choices, then OK when you're done.

I used these properties for my h1 rule, matching the header color and going with all uppercase text.

Wondering what the difference is between the capitalize option and the uppercase option? The former capitalizes only the first letter in each word (great for headlines) and the latter capitalizes everything.

Now let's do the <h2> tag, but don't start with a fresh style. This time, select your h1 rule in the CSS Styles panel and choose Duplicate from the pop-up menu in the upper-right corner. Enter h2 in the Tag field. This will make a copy of the h1 properties as a starting point.

When you click OK, the same style you made for h1 will now apply to h2, but we want to make it a little different...

Double-click the h2 rule in the CSS Styles panel to adjust it. Let's make the type a bit smaller, apply the small-caps Variant (and remove the uppercase option), and give it a weight of 500. Click OK.

See the difference? No? Then let's talk about compatibility. Dreamweaver can't (or won't?) display some CSS properties, especially properties that don't have good browser support. If you preview your page in an up-to-date browser, the small-caps style should work fine, but users of older browsers may not see the small-caps.

In Dreamweaver (top) the weight and small caps aren't showing properly. But these properties are working OK in the Safari browser (bottom). This is a good indication that these settings are non-standard.

Let's go back and change h2 to something a little more standard, shall we? It's your choice!

To wrap up this section, create a new class selector to format the footer, and apply it to the last line of text on the page. Try out any properties that strike your fancy and test them in several browsers to compare the results.

I used the capitalize feature and bold weight on the subhead. I balanced the caps at the top with all caps in the footer, but made the text a more subtle color and size.

All Kinds of Spacing

Don't let print designers have all the fun! With CSS, Web designers are no longer limited to default spacing between lines of text (leading), or words and letters (tracking). Special indenting and alignment properties are also available to totally customize your text display. Most of these features are found in the Block section of the CSS Rule Definition dialog (because they apply to blocks of type).

Double-click the p rule in the CSS Styles panel. The 12 pixel paragraph text is fairly small, so let's add some leading to give it a little breathing room. This property is called Line height. The default is generally a pixel or two larger than the font size. Adding an even larger value spreads the lines further apart, while a smaller value squeezes them together. Try 17 pixels and click Apply to see the results.

The line height gave our text some nice breathing room. Generally a value of few pixels more than the font size works nicely.

Nice! How about some word spacing and letter spacing? Maybe that will give us even more breathing room. Head to the Block section of the CSS Rule Definition window. Choose any pixel values you like (I used 10 pixels for the word spacing and 2 for the letter spacing) and click Apply to see what happens. You'll notice that only the letter spacing appears in Dreamweaver—test in a browser to see the word spacing.

Yikes! These properties make the text too open and airy. Sometimes the defaults are there for a reason—let's remove the letter and word spacing, and just keep the line height. A touch (1 pixel) of letter spacing might be nice on the all-caps header, though.

Double-click the h1 tag in the CSS panel to open the Rule Definition dialog. In the Block category, add 1 pixel of letter spacing. Click Apply to see how it looks. A subtle change, but capital letters look less crowded.

Notice how the header text is right against the edge of the cell? It would be nice to add a margin there. Also, there is too much space below the header.

By default, h1 headers come with a large bottom margin. You might want to tighten this up.

Head to the Box category. Uncheck "Same for all" and enter 10 pixels of Top margin and 5 pixels of Bottom margin. Click OK. The top margin is done, but you might not see a change to the bottom margin. Why? The h2 text also comes with a built-in margin. You've removed the h1 margin, but you still have the h2 margin to contend with.

A top margin has been added to the h1 tag. However, there is still a big gap between the h1 and h2 headers.

Double click the h2 rule in the CSS panel to open the Rule Definition dialog. In the Box category, uncheck "Same for all" and enter a zero in the Top margin field. Click OK and admire the results.

This the effect we were after. The h1 tag has a 5 pixel bottom margin, and the h2 tag has a zero pixel top margin. This adds up to 5 pixels of space.

Now let's jazz up the paragraphs with a nice indenting effect. Text can be indented or outdented using the Text indent settings in the Block category. A positive number indents and a negative number outdents. A 10 pixel indent looks great on the paragraphs, so I added it to my h2 style as well.

This indenting looks pretty classy. Note that while indenting works in most browsers, outdenting isn't visible in all browsers just yet.

Finally, let's take a look at alignment, also found in the Block category. The Text align setting works just like the alignment buttons in the Properties Inspector. So why use CSS to align text? As always, it is cleaner and more convenient to define these properties in an external sheet.

Set the footer to align center. Note that you'll also need to set the text-indent to zero, to override the indent on the paragraph tag.

The footer is enclosed in <p> tags, so it is also affected by the text indent we applied earlier to the paragraphs. Setting the .footer class selector to text-align "center" and text-indent "0" will override the standard paragraph style.

Making Type Beautiful

CSS type formatting is great, but all of these options can be a bit overwhelming! So what can you do to make your CSS style look great? Here are some tips:

 
 

Watch that spacing! As you saw above, increased spacing (especially between letters) can get out of hand and become very difficult to read. Decreased spacing can have a similar effect. The best uses are a few pixels of extra line height for long passages of text, or a touch of letter spacing in short headers.

Emphasize only as necessary. Bold, all caps, italics, color... all of these properties add emphasis. Use them sparingly so it is clear what text is important and what text isn't. Also, don't combine too many emphasized styles on a single page.

When it doubt, keep it simple. There is something to be said for the basics. Our vintage site's paragraph text is simple, clear, and doesn't shout at the reader for attention.

Use classic color choices. Black on white, navy on pale yellow... these color combinations are easy on the eyes and perfect for body text.

Use classic fonts. The font families that are presented by default in the Rule Definition dialog are there for a reason. They're classic, readable, and nearly every user has them installed, so there are no compatibility issues.

Graphics are still a-ok! CSS is great, but it can't do everything. Logos or special headers might look better in graphic format. Coordinate graphics with your CSS text and you'll have a great overall style.

At the Panera Bread site, graphic headers and accents coordinate with the CSS text, resulting in a highly-customized and stylish presentation.

Be consistent. Keep your styles at a minimum. We're using a lot in our sample site, but in general you'll just want one paragraph rule, one emphasis/accent rule, one header rule, one footer rule, and maybe a caption or subhead rule for your body text. Those rules shouldn't vary widely—just enough to help the user discern the importance of each level of text.

Be audience appropriate. Your CSS rules should always relate back to your audience's needs and design expectations. Are they looking for something simple and direct? Artistic and edgy? Sophisticated and dreamy?

 
 

Finally, a great way to make your type pop is to try something new, like something you've only seen in brochures and posters, not on the Web. It will look like you spent a lot of time on your site design if you try an interesting trick like paragraph indenting. Here's another one: try using a large, italic serif font for the first letter in each paragraph—a classy technique often seen in print design.

To recreate this effect, simply make a new class selector with your desired properties and apply it to the first letter of each paragraph.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Styles can be applied to an entire table, or just a row, column, or cell.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Some border styles are non-standard and may appear differently in various browsers.

 

 

 

 

 

 

 

Non-text content areas can also take on interesting styles. Try applying a colored border to images or putting some padding around a Flash movie.

 

 

 

 

 

 

 

 

 

 

 

 

 

Refresh your browser if you can't see your CSS changes. An old version of your CSS file may be cached.

 

 

 

 

 

 

 

 

 

 

 

An ID selector can only be applied once per page. You might use an ID selector for a unique page element like a logo or a footer.

Class selectors can be applied more freely, to multiple elements on the same page.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Background images can also be applied to paragraphs or headers.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The second levels of a bulleted list can also be formatted by redefining the second level of <ul> tags. Enter "ul ul" into the Tag field of the New CSS Rule dialog.

 

 

 

 

Formatting Tables

There's so much more to CSS than formatting text, but without Dreamweaver, this can be tricky stuff to conquer. Thankfully, the same Dreamweaver tools you already know can format your layouts easily and with great new options. Tables and content areas can be formatted with stylish borders (not those old 3D clunkers from the Web's olden days!), backgrounds, and spacing. And just like text, the rules you create can be applied globally and changed in a snap.

Layout Tables

When designing a site with tables using HTML, you have a variety of options: cell spacing, cell padding, border, background color, background image, and more. There's a lot you can do with these features as evidenced by the many beautiful Web sites designed before CSS gained popularity. But with CSS, we can extend these properties visually, and make them easier to work with.

For example, your Web site might use the exact same table settings for every image/caption combination. Picture an e-commerce site with pages of products and their names. CSS will help you to present the tables consistently on each page, and enable you to make quick site-wide changes when needed. Sounds familiar, I know—these are the exact same benefits of using CSS for text formatting!

The tables on the Big Stock Photo site get consistent treatment, like borders and padding, without piles of HTML code.

To try this out, let's insert a table in our Vintage Style Web page. Put your cursor in front of the E in the word "Everything" and go to Insert > Table. Give it two rows and one column, make it 150 pixels wide, and apply zero cell spacing and padding. Leave the Border field blank—delete the zero or any other number.

Select the table and set it to align right using the Properties Inspector. Insert skybar.gif from the vintage folder in the first row.

For now, we just have a basic table and some simple formatting on the caption.

Type this caption in the second row: "Retro candy is popular due to its quirky, nostalgic packaging." Format the caption text however you'd like using a new CSS rule.

Now head to your trusty CSS Styles panel and create a new style. This will be a class style since we don't want it to apply to all of our tables (rarely will you have a style you want to apply to every single table in a site, but if you do, redefine the <table> tag).

Call the class selector .imagetable and visit the Background category of the Rule Definition dialog. Here we have the option to add an background image and determine whether or not it will tile, but we'll just use a solid color to keep it simple. I picked a light aqua.

Our next focus is the Box category—this is where the real fun begins. Forget old HTML cell padding and spacing that was always the same on all sides. Here you can define exact padding and margin measurements for each side of the table.

I used plenty of padding on the top and bottom of the table, and a little on the left and right. This adds some space around the image and caption, showing off some of the background color. The margin adds some space outside of the table—in this case a few pixels on the left so the text doesn't run into the table.

If you haven't seen your handiwork yet, click OK to save the settings. Select the table, then right-click (Control-click Mac) .imagetable in the CSS Styles Panel to apply it. Some padding features won't appear in Dreamweaver, so preview in a browser. When you're done, double-click .imagetable to open the Rule Definition dialog again. Ready to add some more properties?

Viewing your table in the browser will display the padding and margin settings.

Go to the Border category and check out the options in the Style menu—you'll find everything from dotted to dashed to outset to inset. Not only do you have a range of styles to choose from, but you can also decide whether to border all four sides of the table or just the top or bottom edge (or right or left!). You'll also find settings for the border color and thickness. I'm going to add some aqua dots around my table to keep up my retro theme.

Now that's a sweet table. If your border does not appear, check that Border is not set to 0 in the Properties Inspector. This would block any CSS border you create.

Think of all the layout possibilities that these features open up to you! This makes the concept of tables much less rigid, since you can now pinpoint the padding and margins on each side. And you can add great visual touches like non-tiling backgrounds and fancy borders. Apply these settings to specific table columns and rows, and you'll have even more flexibility.

Just remember your table hierarchy and CSS hierarchy from your basic Dreamweaver days: Styles placed on portions of tables will override styles placed on entire tables, and HTML formatting will override CSS formatting.

Imagine what you can do with tabled navigation bars, grids of text and images, and your overall layouts. But also consider how these styles can apply to what tables are truly meant for: Data representation...

Data Tables

HTML tables were originally designed to present data, such as scientific information. Web designers got creative with tables and were able to use them to create complex visual designs, often leaving us to forget the table's original purpose.

Data tables are developed the same way that layout tables are (the code is all the same, we just use the names to differentiate their purposes). So, needless to say, you can style them the same way you would any other table.

Let's look at how we can make a data table suit its purpose using CSS. First, consider the data you are presenting and how to make it readable for the user. Alternating the background colors helps to guide the reader's eye across each row. You can use border treatments as well. Let's look at a finished data table and pick apart the choices made:

This data table is made clear and attractive with some easy CSS techniques.


Download this page and open it in Dreamweaver. Notice in the CSS Styles panel that there are three rules at work here:

 
 

.datatable. This rule sets the font style and size and also adds padding, borders, and a yellow background color to the overall table.

.dataheader. This rule is applied only to the top row. It bolds the column headers and adds a bottom border to separate the headers from the data itself.

.datarow. This rule has been applied to alternating rows of the table to make the data easier to read. A lighter background color is applied (overriding the main table color), and a light, dashed border is used.

 
 

List-Based Navigation

Let's go back to our Vintage Style Source page and take a look at that neglected left navigation bar. A whole lot of nothing is going on here, but to make it look cool, all we need is CSS.

Our First ID Selector: #nav

Let's start by creating an ID selector for the left table cell holding the links. ID selectors can be used to format specific content areas like a left nav.

Create a new CSS rule. Select the Advanced radio button. Type #nav into the Selector field. Don't forget that ID selectors begin with a # hash or pound sign.

Go to the Background category of the Rule Definition dialog. Here, insert the linkbg.gif image from your vintage folder. This image would look strange repeated, so set it to no-repeat and position it top and left. Click OK.

To see this new selector in action, apply the ID to the table cell. Select the left table cell (note that the quickest way to select the cell is to click your cursor anywhere in the cell, then click the <td> tag at the bottom of the Dreamweaver window), then right-click (Control-click Mac) the #nav selector in the CSS panel. Choose Apply from the pop-up menu. Voilà—the background image is in place.

Using background images with rough, torn edges is a great way to soften a boxy table layout.

Unordered Lists: #nav ul

The background image looks great, but the list itself needs some work. We will tackle the unordered list <ul> next.

Click somewhere inside the list. Then use the tag selector in the lower right corner of the document window to select the <ul> tag. Create a new CSS rule. With any luck, you'll find that #nav ul has been filled in for you.

Dreamweaver helps you along by writing a descendant selector for the element you've selected in the Document window. You can edit the selector name as necessary.

#nav ul is a descendant selector. It can be read as: "Select the unordered list within the container element with an ID of #nav." This is very specific. If you had two unordered lists in this layout (maybe one list for the nav, and another list for some data in the content area), only the nav list would be formatted with these settings. Quite handy.

Save #nav ul to your external style sheet and move on to the Box category. Set the margins and padding to 0 (this will remove the default margin around the list). Click OK.

List Items: #nav li

Next up are the list items <li>. Click inside the list, then use the tag selector in the lower left corner to select the <li> tag. Create a new CSS rule. The text #nav li should be entered in the selector field.

In the List category, select none from the Type menu. This will remove the list bullets (they've been bumped over to the left but they are still there).

In the Box category, add some padding around the list items. Uncheck "Same for all" and add some top and left padding.

The top setting adds 10 pixels of padding above each list item. The left setting adds 20 pixels of padding to the left.

Links: #nav a

We've got the list items right where we want them. Now, we'll style the links. Select one of the links, then use the tag selector to select the <a> tag (links are enclosed in anchor tags). Create a new CSS rule for #nav a.

In the Type category, choose a font, size, and color. Set the links in uppercase to match the header. Also, set the decoration to "none" to remove the link underlines.

Hover Effects: #nav a:hover

To finish up, add a hover style so the links change color when on mouse over.

Create a new CSS rule. Type #nav a:hover into the Selector field. In the Text category, set the text color to a dark green.

Save your files and preview them in a browser to see how the hover works!

More Content Formatting
Bulleted Lists

Bulleted lists are an essential content type on most Web sites. Breaking down important information into bulleted lists helps users to quickly scan your information and find exactly what they need. Let's look at some list options.

Download this page and open it in Dreamweaver. You'll see that HTML tags are used to set the basic bulleted list structure. The <ul></ul> tags define an unordered list, and <li></li> mark out each list item. Redefining the <ul> tag with CSS will allow you to set the bullet style and apply other content area formatting, such as background color or border, to the entire list.

Go ahead and redefine your <ul> tag now in the CSS Styles panel. You can make it an internal style, if you like, since we're just working on this one sample page.

Apply some simple text formatting in the Type category of the Rule Definition dialog, then move on to the List category. Notice that you can choose a different bullet style, such as a square, number ("decimal"), or letter. You can even choose your own graphic to use as a bullet to really customize the look.

You will want to set Position to "inside" if you add a background color to the list area—if you leave it blank or choose "outside," the bullets will sit outside of the color or background image and look a little strange.

I used padding, square bullets, and a background color to style my <ul> tags.

To further customize a list, you can create a new class style that is used on the second-level (or any other level) of bulleted items. This helps to distinguish the secondary items, and can even be used to present content in outline format using the Roman and alpha bullet styles.

Italics and a different bullet style were enough to set these list items apart from the rest.

The Body Area

Tables, nav bars, and lists aren't the only content areas you can deal with using CSS. The page body is a content area too. If you redefine the <body> tag of the page, you can use the exact same properties we've been using to add (or remove) margins, backgrounds, and more. One of the most common uses is to set the page margins and padding to zero (in the Box category of the Rule Definition dialog). Sure beats modifying the Page Properties dialog for every single page.

From a visual design perspective, page margins can be a nice feature to help give the page an open and airy feel. However, adding margins in the body area may throw off other areas of your design. I find it useful to set margins at zero on all sides, and then decide at the very end if I should add them back in.

Creating a type selector for the <body> tag is the best way to insert a background color or image for an entire page (and an entire site with an external style sheet!). A simple background color or image carried through all pages of your site makes the user feel at home and can help reinforce your brand and attitude.

CSS Browser Compatibility

A talk about CSS wouldn't be complete without some mention of compatibility. You already know from the experiences above that some CSS features here and there won't work in every browser, even if they show in Dreamweaver. And sometimes they won't show in Dreamweaver, but work OK in most browsers.

Compatibility charts can be found online with a quick search that detail each and every CSS property (there are tons!), and which browsers they work in. This can be useful, but you typically won't be dealing with all of the browsers they note, and certainly not all of the CSS properties they mention. Instead, as for all Web features, you should test your CSS based on your users' expected browsers.

As you test, compile a list of which properties worked, looked wrong, or didn't appear at all for which browsers. Since things can't look exactly the same for all Web users, decide based on some helpful questions:

 
 
  • What CSS features are absolutely essential to the design? Which ones aren't as important? In our vintage site example, the body text formatting was important to make our text readable and applicable to the visual design we created. But the dotted border around the image table was no big deal.

  • Are all of these elements visible in the newest versions of popular Web browsers (Internet Explorer, Firefox, Safari)? If they are not visible in all of the newest browsers, it's time to rethink these "essential" features.

  • Are all of these elements visible in the browsers that are most common to your users? If not, what percentage of viewers will not be able to see them properly? If the percentage is more than 5-10, you will want to do some tweaking.

  • When your essential or non-essential CSS features don't work, is important content obstructed or hidden? Big changes are ahead if the answer is yes! Cool design effects should never interfere with the legibility of the content.

  • If a non-essential CSS feature doesn't look quite right (for example, a dotted border appears solid in some browsers), will the user experience suffer? Usually the answer is no. In this case, just keep the style and understand that not everyone will see it the way you intended.

 
 

Like any other part of a Web site, your CSS should be tested under conditions that are common to your audience, and you'll need to make some compromises when things aren't ideal in every browsing situation.

Extra Practice

In the exercise, you are going to use CSS to format all of the text and content areas on a 10-page Web site. If you'd like a little practice before tackling the exercise, open the extrapractice.html page found in your vintage folder. We've provided text you can use to create new pages for the vintage site. Try out some new text and table styles, or try your hand at some data tables or lists.

Once you're ready, head to the exercise where you'll really go places with CSS!

   

 

Explore the different types of CSS layouts.
Learn how to use the box model to determine column widths.
Work with absolute positioning.
Learn how to align images in CSS designs.
Incorporate multiple page layouts.
 

Exercise
Format a travel agency Web site using advanced CSS techniques.

Discussion
Share your thoughts on Web design with your fellow students.