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 »

PHP Copyright

There’s little that annoys me as much as going to a website that is an authority on some subject, and it has an outdated copyright.

Here’s a very simple script to replace all of your copyrights, so that they are constantly updated with the latest year.

<p>Copyright 2007-<?php echo(date('Y'));?>.</p>

This is, of course, assuming that your copyright began in 2007. Replace 2007 with the year in which the copy was originally created.

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?

Chess Puzzles

Chess Puzzles is a website that I designed and strategically programmed for John Bain two and a half years ago. It’s still going strong, with over ten-thousand visitors monthly playing and participating in the daily puzzles.

Chess Puzzles

The website was built using Wordpress as a CMS, and the chess tactic engine was programmed using a custom Javascript library.

I’m still very proud of this project, and occasionally go back to do a mate in three.

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.

Git Started

Using a version control system is helpful for multiple developer environments, as well as individual tracking and archiving of changes. Here’s how I set mine up using Git.

Note: Setting up a cloned repository between dev and live servers is useful for theme and static file tracking. You wouldn’t want to setup Git on an entire Wordpress directory, however, because tracking uploaded files from the live site “Uploads” folder would cause tracking problems. For Wordpress, specifically, I like to setup Git inside my custom theme directory, where files will not likely be changed on the live website.

Initialize Git on your remote server

  1. SSH into your remote server: $ ssh <username>@<host>
  2. CD to the theme directory: $ cd www/wp-content/themes/<custom_theme_name>
  3. Initialize Git: $ git init
  4. Add the current files (if any): $ git add .
  5. Commit the addition: $ git commit -m "Initial Commit"

Clone a bare repository outside the web root

  1. $ git clone --bare /home/<username>/www/wp-content/themes/>custom_theme_name> /home/<username>/proj.git

Clone the bare repository to your local server

  1. CD to your local server directory. Mine is in MAMP htdocs: $ cd /Applications/MAMP/htdocs/
  2. Create a dev directory by cloning the remote repository: $ git clone ssh://<username>@<host>/home/<username>/proj.git <custom_theme_name>

This will create a local copy of your remote server files. Now you can make changes to these files and keep track of them using Git.

Add, edit, save your local files.

  1. Create a dev branch: $ git branch dev
  2. Checkout the dev branch: $ git checkout dev
  3. Make changes, edits, save files.
  4. Add them to Git.: $ git add .
  5. Commit the changes: $ git commit -m "Made changes"
  6. Checkout the master branch: $ git checkout master
  7. Pull changes from the origin, to see if any changes have been made (if working in a multiple developer environment): $ git pull origin
  8. Resolve any conflicts in code.
  9. Merge the dev and master branch: $ git merge dev
  10. Push the changes to the remote repository: $ git push origin

Pull changes to live website

  1. SSH into remote server
  2. CD to theme directory: $ cd www/wp-content/themes/<custom_theme_name>
  3. Pull new files and edits from the repository: $ git pull /home/<username>/proj.git

And, voila! You have a working repository environment using Git to track changes to your custom Wordpress theme, or other static file directory.

Any questions?

Git Resources

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

Clagnut and CSS

Richard posted a great slideshow presentation on web typography over at his blog. Check out the great link resources on the bottom of each slide.

We should all be so creative with out font-stacks. Thanks, Richard.

By-product: CSS

One month ago 37signals wrote an article about selling your by-products. I often think of that article, because I take down a flurry of notes during the creation-phase of my projects. I like to build structures from which I can add-on, whether it is with a config file or style guideline for code indentation, I appreciate form.

One of these by-products that I have been working from recently has been a “setter” stylesheet. Along the lines of Eric Meyer’s reset.css file, I created a set.css. The point was that I found I could create much leaner CSS when I addressed the multiple elements that would be added/could-be added. After working with database-driven sites for a couple of years, I have found that it is often difficult to predict what elements your clients will somehow manage to insert into the content-management system.

So, here it is in all it’s glory. Feel free to use it as you please – enjoy.


/*
General setter stylesheet used to define basic template styles
URI: http://andyvaughn.com/
Version: 1.0
Last updated: January 31st, 2009

Tags not used for style:
area, b, base, bdo, big,
del, dfn, fieldset, frame,
frameset, head, hr, html,
i, iframe, ins, kbd, link,
map, meta, noframes, noscript,
object, param, q, samp, script,
small, style, title, var
*/

/*------------------------
Native and Containers
--------------------------*/
body {}
div {}
span {}

/*------------
Content
-------------*/
a {}
a:link {}
a:visited {}
a:hover {}
a:active {}
abbr {}
acronym {}
address {}
blockquote {}
cite {}
code {}
dd {}
dl {}
dt {}
em {}
h1 {}
h2 {}
h3 {}
h4 {}
h5 {}
h6 {}
img {}
li {}
ol {}
p {}
pre {}
strong {}
sub {}
sup {}
ul {}

/*------------
Tables
-------------*/
table {}
tbody {}
caption {}
col {}
colgroup {}
td {}
textarea {}
tfoot {}
th {}
thead {}
tr {}
tt {}

/*------------
Forms
-------------*/
button {}
form {}
input {}
label {}
legend {}
optgroup {}
option {}
select {}