• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Ways of Working with CSS

There are three ways that CSS can be implemented on your pages:

  • Inline: Inline CSS refers to styles that are directly in the content. This method is the least desirable type because it affects only the content the styles are directly associated with.

  • Embedded in the head of the HTML document: These styles offer more flexibility because they can be applied to many elements in the document, such as all the paragraphs. These styles will not, however, affect parts of other documents.

  • External: To have styles that affect all the pages of a site, you need to create an external CSS file and create a link to that file in the head section of your HTML documents. This third way enables you to take advantage of the quick site‐wide layout control discussed earlier in this chapter.

Note: These methods can be used alone or in combination with each other. If you do use more than one method, you must know about the Cascade. The Cascade refers to the fact that the style that is closest to an element is the one that takes precedence. For example, say you have styles set up for paragraphs in your external CSS file, and you decide that you need a special treatment for paragraphs on one page of your site. You can set up those styles in the header. The CSS in the header will take precedence over the CSS in the external CSS file because it is closer to the paragraphs of that page. If you then decide that one paragraph in that same document needs a third treatment, you apply inline CSS to just that paragraph. That paragraph — and only that one — will be styled by the inline style.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint