# FAQs

# Frequently Asked Questions

- Why doesn't the heading tag go in the head section?
- Why does the text in my web page wrap differently than the examples?
- How can I create web pages that look exactly the same on all browsers?
- How do I know when to use an id, a class, or a descendant selector?
- My CSS doesn't work. What can I do?

## Why doesn't the heading tag go in the head section?

It's common for students to try to code the heading tags in the head section of the document, but someone doing this won't be happy with the way the browser displays the web page. Even though "heading tag" and "head section" sound similar, always code heading tags in the body section of the web page document.

Back to Top

## Why does the text in my web page wrap differently than the examples?

The text may wrap a little differently because your screen resolution or browser viewport size may not be the same as those on the computer used for the screen captures. That's part of the nature of working with the Web—expect your web pages to look slightly different in the multitude of screen resolutions, browser viewport sizes, and devices that people will use to view your designs.

Back to Top

## How can I create web pages that look exactly the same on all browsers?

You can't.Design with the most popular browsers and screen resolutions in mind, but expect your web pages to look slightly different when displayed by different browsers and on monitors with different screen resolutions. Expect web pages to look even more different when displayed on mobile devices. You'll learn about responsive web design techniques later in this chapter.

Back to Top

## How do I know when to use an id, a class, or a descendant selector?

The most efficient way to configure CSS is to use HTML elements as selectors. However, sometimes you need to be more specific—that's when other types of selectors are useful. Create a class when you need to configure one or more specific objects on a web page in the same way. A class can be applied more than once per web page. An id is similar to a class, but be mindful that it is not valid to apply an id more than once on a web page. To repeat: an id can be used once and only once on each web page. Use an id for a unique item, such as the navigation hyperlink that indicates the current page. As you become more comfortable with CSS, you'll begin to see the power and efficiency of descendant selectors, which allow you to target elements within a specific context (such as all paragraphs in the footer area) without the need to code additional classes or ids within the HTML code.

Back to Top

## My CSS doesn't work. What can I do?

Coding CSS is a detail–oriented process. There are several common errors that can cause the browser not to apply CSS correctly to a web page. With a careful review of your code and the following tips, you should get your CSS working:

- Verify that you are using the colon ":" and semicolon ";" symbols in the right spots—they are easy to confuse. The : symbol should separate the properties from their values. The ; symbol should be placed between each property : value configuration.
- Check that you are not using = signs instead of : between each property and its value.
- Verify that the { and } symbols are properly placed around the style rules for each selector.
- Check the syntax of your selectors, their properties, and property values for correct usage.
- If part of your CSS works and part doesn't, read through the CSS and check to determine the first rule that is not applied. Often the error is in the rule above the rule that is not applied.
- Use the W3C's CSS validator at http://jigsaw.w3.org/css-validator to help you find syntax errors.

Back to Top
Back to Top