| CSS 101: Core CSS Syntax | |||||
|
|||||
Review: CSS Stylings - the core syntax of CSS are reviewed here In our first CSS tutorial the simplicity and power of formating with CSS was explained. And in fact, easy editing has caused CSS to become the killer styling method for an obvious reason - efficiency. For example, say the word comes down from on high that on your websites the font color color has to be blue and the font size has to be increased .This means that if you have used "font=" and "color=" coding in your HTML tags, dozens of entries over many files have to be edited. But if a CSS stylesheet has been used, then changes are made in only one CSS file - and voila all the CSS stylings are changed across all of your web pages. This "one file to change" approach to the always changing formating of Web pages is much simpler than any other method of keeping HTML tags and options. So for example, this one line in a CSS file: Why Not CSS ? "Okay you have made your point, so why has CSS not taken off from the very start of Web development?" Four factors have delayed the widespread adoption of CSS. First, HTML with its extra styling tags got their first, and so many Web developers learned and used them first and were reluctant to make the changeover. As we shall see below, CSS syntax, though simple is very different from HTML - and so there is a learning curve. Second, one major player, Microsoft, has thwarted CSS development by failing to implement it completely in its IE browser and other development software. In 1997 and 1998 when IE was starting to overtake Netscape, Microsoft promised to fully implement CSS and other W3C standards. Over ten years later, IE7 and Microsoft's implementation of CSS are still the ones furthest from the CSS standards(and this is not isolated, Microsoft is also remiss on DOM rationalization, SVG and XForms support, retention of proprietary JavaScript extensions while failing to adopt new standards like E4X and JavaScript. So CSS has had to endure a hostile attitude from the major browser vendor. Third, CSS does compete with other W3C Web Styling standards such as XSLT, XSL, XSL:FO and others. Overtime, even these standards have started to incorporate more CSS-like syntax - but the differences are still notable. Fourth and last but not least, many Web developers have mixed notions on how CSS works. This confusion has been built up by the fact that the IE browser (and its many derivatives)do not implement CSS fully. So devlopers view their CSS as not working where as it is working just fine except for deficiencies in the Microsoft browser. So for these cultural, IT and economic reasons, CSS has taken ten years to "take off". .gogreen {
background-color: #00FF66;
color: #000000;
}
.indent { font-weight: bold; color:white; background-color: #6600CC; margin-left: 20px; } .underbold { font-weight: bolder; text-decoration: underline; } All of 3 of these styles have been used just above or below. .underbold is used at the beginning of this paragraph, .indent is used to create the purple box above, and .gogreen is used to highlight the comments below. It is important to note that in CSS there is no programming: no if-then constructs, no looping nor other programmatic statements. The only other legitimate CSS statement is a comment like so: Okay, so I stretched the truth. As mentioned in the first tutorial, there are a series of Cascading set of rules that determine which CSS statement or property takes precedence if more than one can apply to a specific HTML tag (much more on this later). But before considering any styling rules, lets consider two other CSS Basics: a)what can be styled and b)the 3 ways CSS is used in HTML. These will be the topics of our next tutorial More Core CSS Syntax. Summary As can be seen, CSS is ratjher simple and elegant - its has very simple syntax, no programming although it can be used in programs within such languages as JavaScript or ActionScript. The rela power of CSS is learning how to assign style rules to specific textor other Web elements using the Selector for targeting. Then to create the style, specify one or more formating properties to get the exact look and feel you want. Finally we demo-ed some live CSS used in this tutorial. the next tutorial will explore when and where CSS is used most often. Top of Page Home Tutorials Developers Weblog Graphics Reviews and Tips |
|||||