The Evolution of a professional web developer

Today, I reflected on websites I’ve built in the past and the tools I’ve come to deem essential along the way. Essentially, my evolution as a professional web developer.

When you first start a vocation, highlighting your strengths is the most pressing need. It’s difficult to stand apart from the crowd, differentiate yourself, and often justify that you’re worth the amount you charge. As you progress, your skills gain refinement, your strengths have been highlighted time and again, and the rate you charge is put to question less often.

Then there’s a shift in focus.

Some catastrophe occurs, or you’re put on the precipice of disaster. Inevitably, if you keep working in this profession, you recover, and the situation rights itself. But, you don’t want it to happen again. Hence, the shift in focus. Your weaknesses become the recipient of attention. Resources are allocated to fixing these weaknesses and tools are put in place to ensure success.
Read the rest of this entry »

How to write CSS for a CMS

When writing CSS, it’s very important to pay attention to the “cascading” factor in your stylesheets, as opposed to simply adding style on top of style. When writing CSS for a content management system, it is vital to harness the strength of the cascade, and not repeat yourself.

I’m going to show you how I write stylesheets for content management systems, and minimize extraneous code, whilst keeping the design lean and purposeful.

Stylesheet Reset

First, I start with a clean stylesheet and link to a resetter. This makes sure that you start with a clean foundation, and remove all inherited styles from your browser, whether using IE, Firefox, Safari, Opera, Chrome, or otherwise. Here’s the one I use by Eric Meyer: base reset.

I link to it inside my style.css with the @import declaration, to package it with the media-dependent style.css that I’ve created.

@import url('reset.css');

Ems and relative sizing

Next, I’ll define the body style and a few generals for typography:

body {font-size: 62.5%; font-family: Georgia, Baskerville, serif; background: #FFF; color: #000;}

By setting the font-size to 62.5%, I am doing a baseline font reset to approximately 10 pixels. This allows me to size everything in my layout, line-height, margins, padding, and rest of the structure in “ems” which is the pixel-height of the capital letter em (10 pixels). So, for example, if I’d like to size my container to 960 pixels, I size it to 96ems.

#container {width: 96em; margin: 0 auto; text-align: left;}

This also is convenient for text-resizing in browsers. It allows for the layout to grow with the text.

Defining content

It’s important to clearly define content sections from layout, actionable, header, or navigation sections. Content sections are the editable regions where your client or you will be adding content with a rich-text editor through the administrative panel. For Wordpress, the default is #content.

Once you have defined the content section, it is important to define how general tags will be styled. For example, you need to account for how paragraphs, lists, headers, images, links, and blockquotes will look, because you don’t know what will be added in the future to these sections.

However, instead of simply styling the tags alone, you will want to style these as children of the section #content. The reason for this, is because if you define all paragraphs to have a margin of 20 pixels, then any paragraph tags in the header, sidebar, footer, or other non-content sections will also have this margin, whether you want it to or not.

Good:

#content p {font-size: 1.8em; line-height: 1.5; margin: 0 0 1.5em;}

Bad:

p {font-size: 1.8em; line-height: 1.5; margin: 0 0 1.5em;}

Next, you add style to all of the tags that need to be normally accounted for in a content section. I include a list of commonly added HTML tags on my setter stylesheet post. Now remember, you need to add #content before all of those tags, if you’re styling for a content management system.

Layout, navigation, etc.

You would then want to add style to the layout, navigation, header, and other sections of your site that are not directly editable. This will be much easier now that you defined all your tags specific to the content section. You won’t have to have many declarations like this:

#header p {margin: 0; padding: 0; background: transparent;}

These types of declarations run rampant in CMS stylesheets, simply used to override over-zealous style declarations from earlier stylesheets or from further up the page.

* Important: It is important to note that often users will nest ordered lists inside of unordered lists, images inside of blockquotes, and paragraphs inside of li’s. These need to be accounted for in the cascade. And, thinking ahead will prevent grossly over-sized text, whilst maintaining well-needed contrast.

Any tips I’m forgetting that you like to use?

Museo Sans 500

Today I switched my body font from Qlassik to Museo Sans 500. I also replaced the italic styles to Museo Sans 500 Italic. It’s a great-looking sans-serif font created by Jos Buivenga based on the Museo font.

Museo Sans font

I downloaded the fonts from MyFonts and created the @font-face stack through FontSquirrel.

Let me know what you think.

Single-line CSS

This is somewhat of a personal post. “Personal” in the sense that the information is very subjective and not objective. However, I will try and persuade you of my opinion.

“CSS declarations should be written on a single line.” — me

p {font-size: 1.8em; line-height: 1.5; color: #000; margin: 0 0 1.5em;}

…as opposed to:

p {
font-size: 1.8em;
line-height: 1.5;
color: #000;
margin: 0 0 1.5em;
}

Here’s why:

  1. Conventional indenting styles, such as K&R or BSD Kernal Normal Form are originally for scripting or compiled languages that can nest calls. CSS very, very rarely nests declarations.
  2. CSS documents get extremely long, extremely fast.
  3. When scanning or modifying CSS, you search by tag, class, or ID, not by style.
  4. It reduces document size.

I’ve been writing single-line CSS for the last three years, and I’ve found it to be amazingly easier to read, edit, scan, and teach. I suggest trying it.

Check out my CSS and tell me what you think.

CSS Text-Shadow

If only I didn’t have to use Photoshop to create drop-shadows for my title. I wish I could simply add an outline drop-shadow without having to render my title as an image. Or, what if I wanted to create a Twitter-like logo with thick outlines? Actually, I only want to improve the visibility of my dark text on dark background, but don’t want to ruin my design aesthetic. Isn’t there a declaration in CSS3 that lets me add text-shadow to my text?

Text-Shadow

I’m going to show you how to add a drop-shadow, outline, and improve the visibility of dark on dark text, using CSS.

Let’s take the above header and give it a drop-shadow using the following style declaration:

h3 {text-shadow: 2px 2px black;}

Text-Shadow

What did I do? I defined the shadow to be 2 pixels to the right and 2 pixels to the bottom of the original text. And, the color of the shadow is black.

Let’s now soften it up a bit, as it looks funky. I’m going to add a third dimension attribute of “fuzziness”. This definition goes after the first two.

h3 {text-shadow: 2px 2px 2px black;}

Text-Shadow

That looks a little better. But, what if I want the light to be coming in from the bottom right and not the top left? Let’s change the offset to a negative value.

h3 {text-shadow: -2px -2px 2px black;}

Text-Shadow

Instead of a drop-shadow, I’d like to add an outline. Is this possible, using text-shadow?

h3 {text-shadow: -1px 0 orange, 0 1px orange, 1px 0 orange, 0 -1px orange;}

Text-Shadow

In the above example, I used multiple text-shadows. I don’t know what the maximum number is, but I’ve tried quite a few (as you’ll see below).

Let’s try for a Twitter-style look:
*font “Qlassik Bold-Regular” is taken from the font-family of this site. Credit: Dimitri Castrigue


h3 {font: 4.2em 'QlassikBoldRegular', 'Gill Sans', Arial, sans-serif; color: #3CF; text-transform: lowercase; letter-spacing: -2px; text-shadow: -1px 0 1px white, 0 -1px 1px white, 0 1px 1px white, 1px 0 1px white, 0 0 8px white, 0 0 8px white, 0 0 8px white, 2px 2px 3px black;}

twitter

What I did to accomplish this look is define a lowercase sans-serif font in the same color as Twitter (#3CF). I then squished the text together with negative letter-spacing. With text-shadow, I defined a single-pixel offset outline of white, like I did in the previous example, I then defined a (0 0 8px white) shadow, which basically gives a fuzzy white outline to the text. By repeating it twice, I’m able to intensify the effect. I then defined an eighth shadow, the drop-shadow to make the outline stand apart from the white background.

Have fun!
If you can’t view the above effects, it means your browser does not support CSS3, and you should probably upgrade to a better browser