Showing posts with label css. Show all posts
Showing posts with label css. Show all posts

Friday, May 2, 2008

Open source, distributed, multi-platform, web browser screenshots!

If you're an XHTML and CSS designer you've had the problem where your beautiful design breaks in different browsers. Therefore, you have to recheck your designs in the major browsers. I normally go with IE6+ and Firefox 1.5+.

Due to the huge number of different browsers out there on different Operating Systems, it usually isn't possible to have access to each browser/OS configuration. That is why many designers use as services such as browsercam.com; which is a paid service that generates screenshots of web pages in different browsers running on different operating systems.

Today while looking for alternatives I stumbled upon http://browsershots.org/. This is an Open Source service that takes screenshots of web pages in different browsers and Operating Systems on distributed computers working together via XML-RPC. Contributers to the service register as Screenshot Factories which poll the Server's for screenshot requests in its queue.

The author of project, Johann C. Rocholl, came up with the idea in November 2004. The service has been around since Feb 2005.

Sunday, January 20, 2008

Use invalid CSS in a W3C standards compliant XHTML Document

This is a technique I've decided to offer in the Joomla Extensions I've developed for the Joomla community, in an effort to allow users of the extension to use invalid CSS on their pages, yet still have the page validate with the W3C CSS Validator.

Why use invalid CSS markup?

Now why would you want to use invalid CSS in the first place? The reason is that not all browsers support the W3C recommended CSS2 and CSS3 properties. (Ahem.. Microsoft.. Ahem...). Now with IE7 our CSS is diverging even more. So the use of invalid CSS is quite inevitable.

An Example Maybe?

Lets say you want to make an image transparent. Something that should be quite simple. So you use the W3C recommended CSS property which is opacity:

img {
   opacity:0.50;
}
Amazingly, this piece of CSS does not validate. Try copy and pasting it to the CSS validator.

Not only does it not validate, it doesn't work for a couple of browsers. So, in order to have image transparency across the largest number of browsers, you need:

img {  
   filter:alpha(opacity=50); 
   -moz-opacity:0.50;  
   opacity:0.50; 
   -khtml-opacity:0.50; 
}
Now this 4 property definitions will create exactly 4 errors in the CSS validator. Hahaha.

How do I use invalid CSS markup that validates?

Now the fun part. In our server logs, around 99% of actual users have JavaScript enabled on their browser. So why not use JavaScript to serve your CSS. If you're familiar with JavaScript Remoting, this is exactly the technique applied to a different problem. In JavaScript remoting, JavaScript files are loaded dynamically after the page has fully loaded. With this technique, CSS is loaded dynamically after the page has loaded.

window.onload = function() {
   if (document && document.getElementsByTagName) {
 var head = document.getElementsByTagName('head')[0];
 var link = document.createElement('link');
 link.type = 'text/css';
 link.rel = 'stylesheet';
 link.href = 'invalid_styles.css';
 head.appendChild(link);
   }
};

What we have is a piece of JavaScript that will load the CSS file, invalid_styles.css, after the HTML Document has loaded. So all you need to do is place your invalid CSS in invalid_styles.css. The W3C validator does not render JavaScript generated Elements on the page, thus the page will pass validation, while 99% of your users will enjoy your funky non-W3C CSS styles.

Fallback to valid CSS

What about the other 1%? They will only view your valid CSS since they do not have JavaScript enabled. So they have everything except your fancy styles. The actual layout of your page should be made with valid CSS.

This is not a new concept, it is used a lot for dynamic switching of CSS styles. However, the proposed application is for loading of non-W3C CSS content for extra formating in non-W3C compliant CSS browsers, while keeping all CSS layout styles in valid CSS for users without JavaScript.

Thursday, January 17, 2008

Open Source xHTML, CSS and JavaScript Web Development Tools

Your web development is limited just as much by the tools you use, as by your expertize. Imagine trying to build a house with just your bare hands?

It is very possible to do web development with just notepad.exe, and an ftp client. But doing so seriously handicaps you. Here are a few tips to get you going.

Open Source Web Development Tools

Firefox

If are using Internet Explorer as your browser, please switch to Firefox. Firefox has many extensions developed by Web Developers or Web Developers. The most indispensable one to date is Firebug.

Firebug

Firebug is all around the best client side web based development tool. It allows you to view and edit the source of your HTML, JavaScript and CSS directly on the web page, in real time. It has a JavaScript debugger, DOM viewer, HTTP Request/Response viewer and a lot of other nifty features.

You may also want to look at the other web development extensions provided for Firefox.

Aptana

Aptana is an open source IDE (code editor) built upon Eclipse. It supports Ruby on Rails, Adobe Air, IPhone among other development platforms. Up till now, I haven't found a better Open Source IDE for web developers.

Notepad++

Notepad++ is a drop in replacement for the default notepad.exe on Windows OS. It is also a syntax highlighter for many programming languages and has a built in file manager. This tool offers quick editing of your HTML, CSS, XML etc. if you don't want to waste time loading a full IDE.

WAMP Server

Apache, MySQL, PHP on Windows. If you're still doing your web development over FTP, its about time you worked on a local version of your web server. WAMP allows you to easily install an Apache Server, with PHP and MySQL pre-installed.