4.24.2013
Here are a few quick and dirty upgrades to make your site more usable on mobile and small-screen devices. (Your site is already standards based, right? Good.)
Throw these in your head:
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
And this in your stylesheet:
html { -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; }
This will give your users pretty good usability on their mobile devices (even when changing orientation on iOS devices) without downloading the whole jQuery library.
3.5.2013
Here's a quick PHP snippet which will get the current year (from the PHP server) and display it along with a copyright symbol.
$currYear = date("Y");
echo "© " . $currYear;
Now you can finally stop updating your website's footer every January.
1.16.2013
You've typed <script type="text/javascript" src="foo.js"></script> about a million times. But when have you ever needed to use a type other than text/javascript for a script tag?
HTML5 understands. It assumes a default type="text/javascript" for <script> tags. It also assumes type="text/css" for <link rel="stylesheet"> and <style> tags.
For more cool HTML5 features, check out The three levels of HTML5 usage by Mathias Bynens.
12.23.2012
I've recently fallen in love with a new text editor for all my coding needs - Sublime Text 2. Here are 10 things I love about Sublime Text 2:
- ST2 doesn't make me set up projects; I can just edit the file I need. But if you need to manage code projects, ST2 can do it.
The mini-map. No more scroll-scroll-scroll to get to one section in the super-long file. Just click the appropriate section in the Minimap (on the far right side) and ST2 scrolls right there.
- Control + / to comment the currently selected text. (Or un-comment it, if it's is commented.) If nothing is selected, it comments / uncomments the current line of code. It's context-sensitive - HMTL, CSS and JS all get the right comments.
- ST2's code folding is similar to Dreamweaver's code collapsing, but there's more. When text is selected, press Control + Shift + [ to fold that block of code out of view. Use Control + Shift + ] to unfold.
- When you mouse over the line numbers (in the gutter, little triangles appear for each element. Click that triangle to fold the whole element.
- No more using the mouse to select lines of text - Control + L will select the current line. (Subsequent presses of L while holding Control will select lines further down.)
- Control + Shift + A will select the current tag.
- It's fast - super fast. There's no splash screen and no loading time, even on my poor old Macbook Air.
- F6 to enable / disable spell check. Sometimes you want it, sometimes you don't.
- ST2 has a very user friendly license. You can download a trial-version (nags are the only thing it does). If you buy, you the individual can install your copy on any of your machines - work PC, home PC, laptop, whatever. You also get to use any version of ST2 - it's available for Windows, OSX, and Linux.
1.11.2011
I have been a staunch staunch supporter of conditional comments as the best way to send different CSS to different versions of Internet Explorer. I found that the other options - selector-based CSS rules - were just too hack-y. I was going to have to see a very persuasive technique for me to consider it.
Here it is:
#myelement
{ color: #999; /* shows in all browsers */
*color: #999; /* notice the * for IE7 and below */
_color: #999; /* notice the _ for IE6 and below */
}
The above code is lifted directly from http://briancray.com/2009/04/16/target-ie6-and-ie7-with-only-1-extra-character-in-your-css/.
These are still hacks, so there's always the possibility that the browser vendor could fix the bug that these hacks exploit, or that a new browser will react oddly to this code. For a short term site or a quick and dirty build, I might be willing to take that chance.
I think I'll stick with conditional comments for my larger endeavors. I'm willing to subject the IE6/7 users to the hit of an extra HTTP request.
Remaining blogs about code: