|
||||
|
Principles of CSS
by Nora McDougall-Collins
What is CSS?
CSS (Cascading Style Sheets) is an important web development topic. Knowing CSS will set you apart from many people who use code that other people have written to build websites. In fact, there are many people who build websites that don't really understand how it works because many systems, such as WordPress, have a lot of pre-built CSS. That works just fine, until you want to make a change that requires going into the code. CSS is a type of code that tells a browser how a website should look. CSS also has "best practices" principles that will make your site easier to maintain over the long run. Compared to formatting with HTML, CSS has more options and the code is much cleaner. On the down side, CSS may also take you longer to learn than the old HTML formatting code. This article introduces a few of the underlying principles of CSS and what it looks like. History of CSS More information about the history of CSS CSS Concepts
One important principle of CSS is that content and formatting are separate.
This idea may be a puzzle because most people put something on a web page, highlight it and add the formatting before they go on to the next part of the page. Without being specific about details, with CSS, you could put all your text and graphics on a page and then add all the formatting later - from a different file! In fact, the person putting the content on the page and the person formatting the page don't even have to be the same. Here is a web site that took that idea, created the content, and then let other people build the styles. They made a contest to see what different styles people would come up with!
Another important principle behind CSS is that the formatting for your web site should be uniform.
This is true for your print documents too. From page to page, your fonts should help people feel that they are on the same site. If you use Arial on one page, you shouldn't use Times or Verdana on another page. CSS will help you take control of the formatting on your whole site.
Where the Style Code Exists
Levels or Types of Styles
Presentational Markup v. Semantic Markup Traditional HTML Markup This would look like:
Please note that this example has been adapted from an example given in CSS Zen Garden pages 18, 19 While this method of coding makes the information look good, it doesn't include information about how it fits into the general structure of the information. It is not possible to tell if this is the title of the web page, or a subsection of information. CSS Markup Notice that "Markup Comparison, h2 and Credit indicate what the significance of the text is. Of course these styles will only work if someone has defined what they will look like in an external style sheet. The <h2> is an example of rewritting a traditional HTML tag. This is the second level of heading. CSS Coding Grammar
Notice that the lines of lettering for the description of .SmallText are closer together than the lines for this text is. That is because those lines are a style called SmallTextTight, which is the same as SmallText in everything except the leading. The Subtitles of this article use a style called Subtitle. It is important to plan and name your styles appropriately. SmallText and SmallTextTight say more about what the style looks like than where it will be used. SmallText could be called BodyText because that is how it is being used on this page. The name Subtitle says more about where the sytle will be used on each page.
|
||||
|
Nora McDougall | Missoula, Montana
59801 | 406.253.4045 |
Contact Nora
© 2011, Nora McDougall-Collins |
||||