Proper Tags for Displaying Content Edits

The proper way to mark up changes to an HTML document, when you wish to retain the old content while displaying the new.

I <del>hate</del> <ins>LOVE</ins> my new iPod nano.

The browser defaults are usually a strikeout/cross-through of del, and …

Avatar of Chris Coyier
Chris Coyier on

Adjust Server Time

Sometimes the time set on your server isn’t accurate to what your local time is. If you can’t change it, you can adjust it yourself.

$today = date('Y-m-d-G');
$today = strftime("%Y-%m-%d-%H", strtotime("$today -5 hour"));

If your server thought it was …

Avatar of Chris Coyier
Chris Coyier on

Design Refresh (Version 5)

The new design has been rolled out. Nothing to shockingly different I hope, just a refresher. It’s kind of hard to say, but I think this is the 5th significant iteration of the design at this point. The lines are …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Different Directory Index Page

Normally index.html or index.php is the default page a server serves up when visiting a directory without specifying a file name. You can change this with .htaccess:

DirectoryIndex index2.html
Avatar of Chris Coyier
Chris Coyier on

Cycle Through a List

This code will cycle through an unordered list with an ID of ‘cyclelist’. Can be used on any element with children. Replace “ul#cyclelist li” with the elements you want to cycle through.

$(document).ready(function() {

	 var j = 0;
	 var delay 
Avatar of Chris Coyier
Chris Coyier on

Check if File Exists / Append Number to Name

If the file name exists, returns new file name with _number appended so you don’t overwrite it.

function file_newname($path, $filename){
    if ($pos = strrpos($filename, '.')) {
           $name = substr($filename, 0, $pos);
           $ext = substr($filename, $pos);
    } else {
           $name = 
Avatar of Chris Coyier
Chris Coyier on

Get Directions Form (Google Maps)

<form action="http://maps.google.com/maps" method="get" target="_blank">
   <label for="saddr">Enter your location</label>
   <input type="text" name="saddr" />
   <input type="hidden" name="daddr" value="350 5th Ave New York, NY 10018 (Empire State Building)" />
   <input type="submit" value="Get directions" />
</form>

saddr = blank input field for entering START …

Avatar of Chris Coyier
Chris Coyier on

Style a List with One Pixel

A one-pixel background image can be a pretty versatile thing. With repeat-x it can be a horizontal line, repeat-y makes a vertical line, and repeat makes it a fill color. Just as a little fun proof of concept, we can …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Read/Write Files

Append to a file

function fileWrite($file, $message) {
  fwrite(fopen($file, 'a'), $message . "\n");
}

Read and display entire file

function fileRead($file){
   $lines = file($file);
   foreach ($lines as $line_num => $line) {
      echo  $line,  '</br>';
   }
}
Avatar of Chris Coyier
Chris Coyier on