Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
CSS is short for Cascading Style Sheets, and the name is actually a pretty good description of how they work. A CSS style is merely a collection of formatting attributes that is then used to style an element on the page. A style sheet is a collection of these styles that can either apply to a single page in your site, a range of pages, or your entire site. Understanding some simple rules about CSS will help you write more efficient styles and help you create more manageable Web sites. If you have ever used styles in a program like Word or InDesign, you already have a pretty good idea as to how styles work.
Say, for example, that you want all of your headlines to look the same way. You wouldn't want to format each one individually. It's faster and more efficient to simply write a single style that controls all of your headings. Later, modifying that style will then update all of your headings making your document even more efficient to manage. CSS works this way, but does it on a site-wide basis. So you can literally control the look and feel of your entire site with one file. By placing your CSS in an external file and linking it to all the pages in your site, you can control any updates to your site's formatting through that single file.
CSS doesn't have to be placed in an external file, however. When you are creating your CSS, you have several options about where the styles should be placed. You can place styles in external files and then link them to pages. You can embed the styles within an individual Web page, or you can create inline styles that are actually part of the single element in your code. Now for the most part, inline styles are discouraged, but are occasionally very useful for items that will be used in basic user agents, such as HTML Emails.
Deciding where to place your styles has a lot to do with how you wish to take advantage of the cascade itself. As a general rule, inline styles will overwrite embedded styles, which will, in turn, overwrite external styles. That makes it possible to have global styles in external documents, and then use the cascade to overwrite some of those styles locally in specific pages. Now that we have a basic understanding of how styles work, we will examine a style rule in detail in our next movie, so that we can understand the structure and syntax of the CSS rule.
Get unlimited access to all courses for just $25/month.Become a member