I've added a new article to our support knowledgebase about how CSS works and is integrated in Expression Web. You can view the full article text here...
If you're a long-time FrontPage user, you're probably used to using the
Formatting toolbar to make your text bold, italic, colored, use different fonts,
etc. If you ever took a glimpse at the generated HTML code, you would have seen
lots of <font> tags -- perhaps something like this:
<h1><font color="#000099" size="5" face="AGaramond, Garamond, Georgia,
serif">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </font></h1>
<p><b><font size="2" color="#CC0000" face="Georgia, serif">In volutpat
consectetuer nulla.</font></b><font face="Verdana" size="2"
color="#CC0000"></font></p>
Expression Web, in keeping with today's web standards, has thrown out the <font> tag altogether and now generates formatting using CSS, or Cascading Style Sheets. (If you need to be convinced that CSS is a good thing, take a look at my Intro to CSS ("A Baking Analogy") article, or "Why CSS?" from the PixelMill newsletter.) With CSS, not only can you end up with cleaner, leaner code, but CSS gives you a lot more options for formatting not just text but the display properties of any object or element on your page.
CSS code is different from HTML code, which means it has its own rules. But it was designed to work together with HTML to format your web content.
If you wanted bold red text in a paragraph before (using the formatting toolbar), you would have had HTML code that looked like this:
<b><font color="#ff000">Red text</font></b>
With CSS, you can streamline the code by creating separate CSS code that looks like this:
.red { color: #ff0000; }
In the HTML code, you can then use this "class" as many times as you'd like.
<b
class="red">Red text</b><p class="red">An entire paragraph of red text</p><td class="red">Everything is red!</td>In FrontPage, applying red text would result in multiple instances of the <font> tag, and if you wanted to change the color later, you'd have to go through every page and select the text and change the color. With CSS, you can simply edit the stylesheet to use a different color:
.red { color: #660000; }
... and ALL the red text in your site will change!
In FrontPage, you could generate CSS using the Style dialog box. Expression Web provides two ways of creating CSS code:
<head>
area of your page. If you use the Formatting toolbar to apply the same
property, Expression Web will reuse styles as appropriate. (See Advice and
tips below about the Formatting toolbar.)If you're totally new to CSS but want to use Expression Web to create standards-compliant sites, I have some advice for you:
body element (in HTML, the
body element contains everything else that shows on your page) to set a
default font, text size, and color for your entire site. As another example,
drawing from my "red text" example above, you can create a global class for
".red" text that can be reused throughout your site and applied to your
text, instead of using the Formatting toolbar and ending up with multiple
styles that do the same thing.To learn more about creating and using CSS in Expression Web, take a look at "Transitioning to CSS" and scroll down to the section on "Working with CSS Templates in Expression Web."
To learn the basics of CSS, take a look at "Learning CSS." This article gives some sample code of how you can use CSS and provides information on the different CSS properties and what they are used for, but it doesn't go into great detail on actually creating complex layouts with CSS (it's focused more on the kind of CSS you might find in one of our templates). The article is a great place to start to familiarize yourself with CSS, and there are links to other resources if you'd like to learn more.