Pro CSS Techniques: Book Review

In Pro CSS Techniques, Jeff Croft, Ian Lloyd and Dan Rubin decided to take a real-world approach to CSS and write a collection of techniques that can be incorporated into actual projects.  They discuss CSS maintainability, browser compatibility, using CSS' inheritance and specificity all with an eye to practicality. They provide enough background with example to explain why CSS works, how it works, when it should be used and when workarounds needs to be employed.

What is isn't
This is not an introduction to CSS and it's expected that you can read XHTML code snippets. And if you're looking for clever, experimental CSS to wow your instructor, this is the wrong book for you. Pro CSS Techniques takes a practical approach to incorporating CSS into real-world projects (and yes, they do discuss recalcitrant browsers and workarounds).

What it is
This is a very handy book to have in your library. It’s a collection of techniques, thoughts and ideas that can be put to use immediately. The initial chapters give a good background on CSS and the language of style sheets, getting into such details as universal star selector, sibling selector types and how the rules and selectors interact (it’s all about the cascade). One chapter is devoted to hacks and workarounds with specific examples on adjusting for IE6 and IE7's "fixes". Yes, coding to standards is what we aim for, but when the browsers fall short of standards, workarounds are used. And that's where the practicality of this book comes in handy.

Should I get it
If you've learned CSS on your own or by viewing others' source code or picking up tidbits and hints from articles and blogs, this book will round out your knowledge nicely. It gives a good explanation of the aspects of CSS and how you can use it for layouts, typography, and form elements. The appendices are a handy reference for CSS properties, selectors and browser compatibility (including IE7). And the chapter on troubleshooting, "Everything Falls Apart", is a good guide to solving conflicting CSS problems.

Summary
Pro CSS Techniques is a valuable resource that offers helpful techniques applied to real-world projects. In addition, the authors give enough detail on the background and explanation of CSS to fill in any knowledge gaps you may have.

CSS Tools: 'Style Master'

Stylemaster_20060710103706I visited Apple's development tools section earlier today, and came across "Style Master", a css editing tool. I decided to take the plunge and see what it can do. Here’s a quick review.

Currently, I use Adobe Go Live CS2 currently to edit my style sheets, simply because it’s a lot easier to use the same tool for your entire web workflow. So I will compare some of the features in Style Master to it. Keep in mind, Go Live does a lot more than style sheets, but with it's latest version, CS2, adding a number of style sheet related features, editing and manipulating CSS is a major part of the Go Live interface.

Helpful for Beginners
Style Master looks to be designed especially for those at or near the start of their CSS adventures. The Read Me file answered some fairly beginner questions, and the WYSIWYG toolbar makes it easy to edit your style sheets without having to touch any code.

There's even a Style Sheet wizard, which steps you through the process of creating a CSS document with the settings you want based on a series of simple questions.

Debugging and Validation
The validation and compliance tools are quite nice. I especially like the bar at the bottom of the window that tells you weather your code is valid CSS1 and CSS 2, and weather it will render properly on every major browser since IE4. There's also a 'Debug' menu option that contains a number of useful sub options, such as 'Validate in Browser' which sends the file to the W3C for validation checking in your selected browser, and 'Report Unused Statements' which will check weather the style you have selected is not connected to any elements in your HTML documents.

Interface
The interface is quite easy to use. I picked up the general idea in about 15 seconds without the tutorial or set up guide. The major features are duplicated on the tool bar as icons, although there are some useful tools that are hidden all the way at the bottom of the window, including the Add and Edit selector actions.

Features
The dynamic search feature makes it easy to find the selector you are looking for in large files. One advantage it has in this regard over Go Live, is that you don't searches aren’t case sensitive, so you can find selectors even if you don't remember what you've capitalized.

Picture1_1
The properties editor is a bit more powerful then the equivalent in Go Live, which groups related properties, and sometimes makes it cumbersome to find the one you want. In Style Master you have the option to view all properties that can be applied to a selector in an alphabetical list.

Performance
The only trouble I got was when I tried to create a style sheet using the Wizard. After I hit submit, it took about two minutes for the application to create the file and open it, during which time I had no control over the interface. I would never use the Wizard in any case, so this wouldn't affect my workflow. However if you like the idea of a style sheet wizard, beware--this might be a little frustrating.

Overall, Style Master is a nice little Style Sheet builder/editor with a number of advantages over Go Live CS2. It has a number of features for those who are unwilling or unable to hand code CSS. It also provides the CSS pro a simpler and easier way to find and edit styles.


CSS Tools: 'Style Master'

Stylemaster_20060710103706I visited Apple's development tools section earlier today, and came across "Style Master", a css editing tool. I decided to take the plunge and see what it can do. Here’s a quick review.

Currently, I use Adobe Go Live CS2 currently to edit my style sheets, simply because it’s a lot easier to use the same tool for your entire web workflow. So I will compare some of the features in Style Master to it. Keep in mind, Go Live does a lot more than style sheets, but with it's latest version, CS2, adding a number of style sheet related features, editing and manipulating CSS is a major part of the Go Live interface.

Helpful for Beginners
Style Master looks to be designed especially for those at or near the start of their CSS adventures. The Read Me file answered some fairly beginner questions, and the WYSIWYG toolbar makes it easy to edit your style sheets without having to touch any code.

There's even a Style Sheet wizard, which steps you through the process of creating a CSS document with the settings you want based on a series of simple questions.

Debugging and Validation
The validation and compliance tools are quite nice. I especially like the bar at the bottom of the window that tells you weather your code is valid CSS1 and CSS 2, and weather it will render properly on every major browser since IE4. There's also a 'Debug' menu option that contains a number of useful sub options, such as 'Validate in Browser' which sends the file to the W3C for validation checking in your selected browser, and 'Report Unused Statements' which will check weather the style you have selected is not connected to any elements in your HTML documents.

Interface
The interface is quite easy to use. I picked up the general idea in about 15 seconds without the tutorial or set up guide. The major features are duplicated on the tool bar as icons, although there are some useful tools that are hidden all the way at the bottom of the window, including the Add and Edit selector actions.

Features
The dynamic search feature makes it easy to find the selector you are looking for in large files. One advantage it has in this regard over Go Live, is that you don't searches aren’t case sensitive, so you can find selectors even if you don't remember what you've capitalized.

Picture1_1
The properties editor is a bit more powerful then the equivalent in Go Live, which groups related properties, and sometimes makes it cumbersome to find the one you want. In Style Master you have the option to view all properties that can be applied to a selector in an alphabetical list.

Performance
The only trouble I got was when I tried to create a style sheet using the Wizard. After I hit submit, it took about two minutes for the application to create the file and open it, during which time I had no control over the interface. I would never use the Wizard in any case, so this wouldn't affect my workflow. However if you like the idea of a style sheet wizard, beware--this might be a little frustrating.

Overall, Style Master is a nice little Style Sheet builder/editor with a number of advantages over Go Live CS2. It has a number of features for those who are unwilling or unable to hand code CSS. It also provides the CSS pro a simpler and easier way to find and edit styles.


Multi Column layout in CSS

The World Wide Web consortium’s (W3C) CSS working group recently released a draft of a new multi column layout module--to be included (with possible modifications) into the CSS 3  specs.  For those web developers that have been lamenting the lack of adequate multi column support in current supported versions of the CSS specs, this is an exciting and welcome addition.

In this article I will identify the basic principles of the Multi-Column model as described by the W3C, and give some examples of how it might be used to layout web pages much more easily than is possible today.

Currently, all content within a content box flows left to right, and then top to bottom, filling the entire content box (minus padding). Multi Column Layout uses a new type of model for the positioning and flow of content within a content box.

The use of the column-box (or column for short) will specifiy that content within a content-box flow in a columnar fashion. Just like table cells in an HTML table. Columns in a content-box will flow from left to right.  The content within each column flows in the normal top to bottom direction.  From the W3C paper:

Content is flowed  into column boxes in the block-progression-direction, and column boxes (or  "columns", for short) are flowed into content boxes in the  inline-progression-direction.

The implications for web developers coding in CSS are tremendous.  The only way to create multiple columns in CSS now is by jumping through hoops.  A simple two column layout requires breaking a content-box into two child boxes and floating them.  Try adding another column and you’ll find it almost a nightmare to code it with enough hacks so that every major browser renders it to a  reasonable degree of similarity.  I have yet to see a fluid four column layout using current CSS box model techniques.

The Working draft offers promise that we can look forward to bieng able to code much more sophisticated web page layouts that are standards compliant,cross browser compatible, and flexible enough to render properly on many different types of devices.
The datails: Multi Column Layout using the ‘column’ property
Multi-column layout will be easy to create in CSS3.  Simply use the ‘column’ declaration on the appropriate content-box.

The Column-Count property
To specify the number of columns you want your parent content-box to be split into, simply use the ‘column-count’ property

body { column-count: 2 }

The Column-Width property
You can also specify the width of the columns by using the ‘column-width’ property.  If you don’t set the column count explicitly, the number of columns will be determined by the column width and the avaiable space within the parent content-box.

body { column-width: 15em }

The Columns shorthand
Use The shorthand ‘columns’ property to affect both the column width and the number of columns.

body { columns: 2 15em }

The Column-Rule and Column-Gap Properties
Use the column rule property to define the style of the rules that separate columns.  It is similar to the border property, and therefore takes similar values.
Use the Column-Gap property to define the width of the gutter in between columns.

body {
  column-gap: 1em;
  column-rule: thin solid black;
}

The ‘column-break-before’, ‘column-break-after’ and ‘column-break-inside’ properties
Use these properties to tell the browser where to break the content within columns.  In other words, the browser needs to know there to move content into a new column.  These properties specify when and where to move content to a the next xolumn over.

h1 { column-break-before: always }
h2 { column-break-after: avoid }
h1, h2 { column-break-inside: avoid }

Multi Column Layouts applied
Using the properties described above, we can quickly layout a page that uses a fluid four column grid in which each column resizes with the width of the browser window--something that is impossible using current CSS techniques. The code below will do the trick…

Create a content-box:

<div></div>

give it an identifier:

<div id=”mainContent”></div>

Now insert your content:

<div id=”mainContent”> Lorem ipsum dolar sit amet, cons incidunt ut labore et dolore magn trud exercitation ullamcorpor susc vel eum irure dolor in reprehende dolore eu fugiat nulla pariatur…</div>

Create a style sheet and style “mainContent” like so…

#mainContent {
width: 100%;
column-count: 4;
column-gutter: 15px;
column-rule: solid black thin;
}

and voila…
Content within “mainContent” flows from one column to the next.  And since the number of columns is explicitly stated and the column width has been set to auto (by default), the columns resize so that no matter what the window dimensions are, there will be 4 of them…Multicolumnlayout_2

Technorati

  • --