Just getting started?

What's new in Adobe Dreamweaver CS5

Do I have to learn HTML to create a web site?

Before you create your first Web page, set up your site in Dreamweaver

Test your Web site

Browser Test your Web site in Internet Explorer, Firefox, Safari, and other web browers

Award-Winning Dreamweaver Training Videos

Janine Warner, training videos in Dreamweaver

Learn Fast with Janine's Dreamweaver Videos

Dreamweaver FAQ

FAQ: Get answers to your questions fast, and discover the answers to questions you may not have thought of yet... Search the Dreamweaver FAQ

Featured Tutorials

Using Dreamweaver to edit a WordPress blog

Adding E-commerce and a shopping cart with Google Checkout is so easy

Google Checkout

How do you register a domain name? (Tips for finding the domain you want now.)

Choosing the best web hosting service to publish your site

Designing with CSS

Why use Cascading Style Sheets (CSS)?

Customize a CSS Layout
(Dreamweaver CS3 or CS4)

ecommerce web site example

Align Images with CSS floats
(Dreamweaver CS3 or CS4)

Choose the right CSS selector : Class, ID, Tag, or Compound
( Dreamweaver CS4)

Choose the right CSS Selector: Class, Tag, or Advanced
(Dreamweaver CS3)

Templates & Themes

How to use templates in blogs and web sites

Designing templates for Adobe Dreamweaver

Using Dreamweaver to Edit WordPress themes

California Wildlife Photography sample web site

Cool Addititions: Traffic Stats, Google AdSense, Ecommerce & more

Test your Web site in Internet Explorer, Firefox, Safari, and other web browers

Traffic counters, email spam protection, newsletter services, favicons, and more

How to add Google AdSense, Flickr, YouTube, and widgets

Creating drop-down menus with Spry

Add a Drop-Down Menu in Dreamweaver CS3 or CS4

Edit a Spry Drop-Down Menu created with Dreamweaver

Create Collapsible Panels with Spry in Adobe Dreamweaver CS3 or CS4

Learn More

Quick Quiz: Test your Dreamweaver Savvy
(play and learn)

Review: What's the best Web design program? Adobe Dreamweaver or GoLive, Microsoft Expression Web or FrontPage?

Adding Flash (.flv & .swf) to Web Pages

Insert a Flash File (.swf) (Dreamweaver CS3, Cs4)

Insert a Flash Video (.flv)
(Dreamweaver CS3, CS4)

Convert video into Flash with the Flash Video Encoder

Dreamweaver CSS Tips

Create a Navigation Bar with an Unordered List and CSS
(Dreamweaver CS3)

Troubleshooting CSS (Dreamweaver CS3)

Compare Layout Options: Tables/Layers/AP Divs/CSS(Dreamweaver 8, CS3, MX)

Review: More places to learn advanced CSS tricks & techniques

Editing HTML Code

Editing HTML Code in Dreamweaver

Connect an HTML Form to a Script in Dreamweaver (Dreamweaver CS3, CS4)

Dreamweaver Behaviors and Extensions

Use Swap Image Behavior to Create Multiple Rollovers
(Dreamweaver CS3, CS4)

Swap Image Behavior

Use a Behavior to Launch a New Browser Window (Dreamweaver CS3, CS4)

Add new features to Dreamweaver with Extensions (Dreamweaver 8 and CS3)

What's new in Adobe Dreamweaver CS4

Getting started with Blogs and CMS tools

What's the difference between a Web site and a blog?

Big Picture: The advantages (and challenges) of a blog, content managment system (CMS), or other dynamic database site

Review: What's the difference between WordPress, Joomla and Drupal and how do Content Management Systems Work?

Blogging: Which blog program is best: WordPress, TypePad, or Blogger?

Why do you compare web design and blogs to building a house or a prefab?

How do I set up a server on my computer to test and view blogs and templates?

partners and sponsors

Dreamweaver CS5 Training Video

_______

Dreamweaver FAQ

Search for answers to your questions, and maybe even a few you hadn't thought of yet, in the Dreamweaver FAQ.

_______

Trusted by over 7 million customers!

Choosing the right Selector when creating styles in Dreamweaver 8 and CS3

What's the best Selector, Class, Tag, or Advanced?

Even if you’ve been working with CSS for a while, understanding (and remembering) the differences among the various types of style selectors can be a challenge.

As you can see in this screenshot of Dreamweaver's New CSS Rule dialog, the first thing you need to do is specify if you want to create a rule using a class, tag, or advanced style selector.

CSS Selectors

If you’re still trying to understand the differences among the various selector options and when you should choose one or another, this tutorial provides an overview of some of the most common CSS selector options and how best to use them in Dreamweaver 8 and CS3.

TIP: Don’t feel you have to memorize all this. Instead, consider bookmarking or printing this page so you can refer to this list of selectors as you create your styles.

Partners and sponsors

Dreamweaver CS4 Video Training

Class Selectors

The class selector is the most versatile selector option. Class styles can be used to format any element (from text to images to multimedia) and they can be used as many times as you like on any page in a Web site.
Class style names always begin with a period, thus a class style might look like this:

.caption.

Dreamweaver will help you with the period (more commonly called a dot). If you forget to include a dot when you create a style with a class sector, Dreamweaver will add one to the beginning of the style name for you.

Because class styles must be applied to an element before they take effect, these styles are appear in the Styles and CSS drop-down lists in the Property inspector in Dreamweaver. (Styles created with tag or advanced selector do not appear in these drop-down lists because they are not applied in the same way.)

In the screenshot shown here, you can see the class styles .fltrt (float right) and .fltlft (float left) which are included in most of the predesigned CSS layouts included with Dreamweaver. These styles are designed to align images and other elements to the left or right so that text or other elements can wrap around them. Creating styles to align images and other elements is one of the most common uses of the class selector.

Class selectors

Tag Selectors

The tag selector is used to redefine existing HTML tags. Select this option if you want to change the formatting options for an HTML tag, such as the H1 (heading 1) tag or the UL (unordered list) tag. When you choose the tag selector in Dreamweaver, you can type in any HTML tag or use the drop-down list in the New CSS Rule dialog (shown in this figure), to select from a list of HTML tags. (This is a handy reference because the name of the tag style must match the HTML tag exactly for it to work.)

In many cases, redefining existing HTML tags with CSS has advantages over creating new styles. For example, content formatted with the H1 tag is well recognized on the Web as the most important text on a page. For that reason, many search engines give priority to text formatted with the H1 tag. Similarly, the hierarchical structure of the H1-H6 tags helps ensure that even if a visitor to your site changes the text size in their Web browser, text formatted with the H1 tag will still be larger relative to text formatted with an H2 tag, which will be larger than text formatted with the H3 tag, etc.

The ability to change the appearance of heading and other tags with CSS makes it possible to retain these advantages while still being able to use the font, size, color, spacing, and other formatting options that you prefer in your Web design. When you use the tag selector, the style definition is automatically applied to any text or other element that has been formatted with the corresponding tag. Thus, if you’ve formatted a headline with the H1 tag and then create an H1 style it will automatically apply to the headline.

Tag Selectors

Creating ID Styles with the Advanced Selector

The Advanced Selector option in Dreamweaver can be used for multiple style types, including ID styles. ID styles must begin with a # sign, but Dreamweaver does not add it automatically. If you want to create an ID style, you have to type the # sign at the beginning of the name. For example, #story (Note: do not include any space between the # and the style name).

ID styles should only be used once per page and are ideally suited to formatting div tags and other block level elements. Thus, ID styles are great for creating page layouts. In the predesigned CSS layouts included in Dreamweaver, all of the designs are created by combining a series of HTML div tags with ID styles using names like #container, #wrapper, and #footer. This is a common convention on the Web, and is considered by many designers to be the best approach to designing Web pages today.

ID Selectors

Creating Descendent Styles with the Advanced Selector

The Advanced selector can also be used to create descendent styles. Descendent styles combine two or more styles to create a style definition that only displays when one style is contained within another. Descendent styles are useful when you want to do something like use the H1 tag in multiple places on the same web page with different formatting. For example, you could create one style for headlines that appear in the main story area of a page and then create another style for headlines that appear in the sidebar on the page and still use the H1 tag to format both.

Descendent styles are created by combining ID, class, or tag styles and look like this:

#sidebar H1

Note that you must include a space between each name or tag. In this example, the style definition will apply only to H1 tags that appear within another element, such as a div, that is formatted with an ID style #sidebar.

If a descendent style combines more than one tag, it is written like this:

#sidebar h1 a

Again, you must include a space between each name or tag. In this case, the defined style for the a (anchor, or link tag) will only apply when the link is located inside an element formatted with the H1 tag that is also inside an element formatted with the #sidebar tag. A descendent style like this makes it possible to create links that look different when they appear in a headline in the sidebar of a page than when they appear in other parts of the page.

Advanced Selectors

Once you learn the differences among these style selector options and when they are best used, you’re well on your way to mastering the art of creating Web pages with CSS in Dreamweaver.

This article was originally published on the Layers Magazine Web site.

Partners and sponsors

Dreamweaver CS4 Video Training