Ask the CSS Guy

Troubleshooting with <base>

As powerful as Firebug is for inserting HTML and CSS on the fly, sometimes you just want to save a local version of the page so that HTML manipulation can be saved and tested across browsers.

I just wanted to share a tip on how easy this is to do. Right click, view source, and save it as an html file. If you're lucky, the page will load right up, bringing in the CSS/JavaScript files that's being used on its original domain.

For some sites, you have to give a little guidance. Like today, I went to wired.com, viewed and saved the html source. You can view the result here.

Yuck, it's missing styles. That's not what we wanted.

But by inserting a little code in head, we can grab everything the page uses from the site. After the opening head tag, insert the following:

<base href="http://www.wired.com/" />

and then resave the file. View the result, and you should see the page just as it is meant to be seen at its original address.

I can modify my local copy to my heart's content, putting new or modified CSS in style tags until I have it just right, then commit the changes to something more permanent. I use this all the time when troubleshooting defects, especially when needing to see how inserting some new element in the HTML will affect IE. Hopefully, it will help some of you, too.

And note that the wired.com example might work for today, but if they ever redesign, this article's example won't mean jack. I apologize in advance.

Comments (6)

Bart said:

Ok, this one is soo great!:)
I know the base tag but never thought of using it this way, which would save me a lot of time.
Thanks a lot!

Dan said:

Thanks for the post. I've been working with a CMS that uses the base tag this way, and your description here made it make sense to me.

PETERV said:

Thank you! I wish I'd seen this before spending all day uploading files to test. Things will go a lot smoother now! I'll be checking back regularly for more great tips.

Sheron said:

Wow cool tip! I've faced this problem before...But never heard of the base tag.

Thanks... :-)

Gillian said:

Awesome! Thanks so much for sharing! :)

TFHackett said:

I think you just made my job as a web designer/developer much much easier. Thanks!

 

Post a comment