H3RALD.com v8.3 Released

A new minimalist design, powered by Twitter Bootstrap

One of the many things that really bothered me about my web site was the fact that it didn’t look good on my iPhone, or any small screen for that matter.

Years ago I read about responsive web design, media queries, etc., but I never had the will or the time to dive into the subject. Then Twitter Bootstrap came out, and it changed everything.

Not only Bootstrap provides a very solid HTML boilerplate and grid system, it also comes with some very nice and complete styles for every HTML element, a few Javascript-enhanced UI components, and best of all it is fully responsive.

Getting to know Bootstrap & its CSS wizardry

Redesigning H3RALD.com using Twitter Bootstrap turned out to be fairly easy. I headed up to the Customize and Download page and set a few variables like the font to use (the beautiful Crimson text), the link color and so on, and downloaded the lot.

I more or less completely forgot about my old CSS stylesheets and went with Bootstrap all the way. I was happy with a lot of the defaults, but I had to add a few rules and overrides for:

  • headings
  • line heights
  • A few custom classes I use extensively, like add a text-align: justify; for the hyphenate class.

Now, one of the cool things of Bootstrap is that it comes with smart defaults, and that it lets you add specific features to elements simply by adding a CSS class to them. Take a look at how buttons are constructed, for instance. Normal button? Sure:


<button class="btn">Click Me!</button>

That’s grey with black text. Boring. Want it red? Sure, add the .btn-danger class:


<button class="btn btn-danger">Click Me!</button>

Too big? No problem, make it smaller with .btn-sm, so we have:


<button class="btn btn-danger btn-small">Click Me!</button>

Wouldn’t it be nice to have a nice icon in it? Add an empty <i> element with a suitable class and there you have a nice Glyphicon before the button text (or you can use other icon fonts, like FontAwesome).


<button class="btn btn-danger btn-sm"><i class="fa fa-check"></i> Click Me!</button>

…You get the picture. And it works surprisingly well — if you embrace its philosophy, that is. Just like Rails & Co.: an opinionated framework.

The only thing that bugged me about all this was that by adding smart CSS classes to elements you’re actually specifying how something looks like by polluting HTML code. Granted, if your stylesheet doesn’t include a .btn-inverse your buttons won’t automagically become black, but you know what I mean. Although in a very nice way, by following Bootstrap’s way of doing things you are no longer separating content from presentation. And in the next six months, when I’ll ditch Bootstrap for something better, all the previews of the code snippets above won’t work unless I keep using the Bootstrap stylesheet or at least some of its button classes.

The real problems arise for the stylesheets provided for general elements. By default, Bootstrap styles tables with no borders or colors. What if I wanted just ordinary tables to be striped and bordered? Sure, I can add the .table-striped and .table-bordered classes to all tables, and that’s it. In EVERY table. Or of course undo bootstrap’s magic by overriding the CSS rules for ordinary tables, to include the rules specified for .table-striped and .table-bordered. Copy & paste someone else’s code? Not nice.

Luckily, using SASS finally paid off, and here’s how to do it in a nice and tidy way:


@import "_bootstrap.scss"; 
/* The bootstrap stylesheet - just changed its extension and prepended an underscore, nothing more */

table {
  @extend .table;
  @extend .table-striped;
  @extend .table-bordered;
}

There you go. All tables (ordinary <table> elements with no silly classes attached) are now bordered and striped.

Header & navigation bar

As far as the main site header goes, I decided to use the same one for all pages, containing:

  • The site logo
  • The search input box (powered by Google Custom Search Engine
  • A responsive navigation bar with links to all the main sections of the site

As far as the navigation bar goes, that’s pure Bootstrap goodness, nothing new there (except the serif font), look it up.

For the logo… Well, I had this nice plan of using just plain CSS and web fonts to make it (hell, it’s basically the word “H3RALD”, with the 3 slightly bigger and moved a bit). It worked mostly fine (in webkit browser and in Opera), but Firefox didn’t like it much, and IE… well, some old versions of IE don’t play nice with web fonts, so I decided to make a nice PNG image and stick it there instead. Less hassle, it works everywhere, job done.

The search input box was a bit more of a challenge. I read up on the new Custom Search Element Control API, discovered that Google decided that web designers don’t know Javascript or CSS nowadays and proposed a new API that has numerous advantages like:

  • Easy to use syntax—no JavaScript knowledge required.
  • Custom Search elements (search boxes and results pages) are rendered based on settings stored on the CSE servers (along with any client-side customization). Server-side changes don’t require you to copy and paste any new code into your site

Thanks Google. Now every time I change my stylesheet I have to remember to go back to your page and change the link colors etc. And if I decide to hide the page URL underneath the link in the results? I can’t. And that’s why I decided to reverse engineer their CSS and provide my overrides. Nasty, but at least I have some control! They’re all here, if you are curious.

Other minor changes & tweaks

Other changes from the previous design were relatively minimal:

  • No more newspaper-style home page with five columns, two will suffice.
  • A brand new Tags page, listing… well, all the site tags that were previously in the Archives pages (now only listing articles by month of publication)
  • No more Links page. No need for it.
  • A new, minimalist Contact page, featuring some of the nice Zocial font icons.
  • No more social buttons on pages. If you use social networks like Twitter, Facebook or Google+ you already know how to share items using bookmarklets or browser extensions. No need to plague my web site with their nasty buttons, badges, ribbons & alike.
  • No ads! I have a full-time job, my site uses free and open source technologies, and I write because I like to do so, not to make money. And I can afford the few bucks necessary to pay the hosting provider. That’s why there are NO ADS on H3RALD.com anymore (*).

(*): For now, that is. Then I’ll probably change my mind, but until then enjoy the true no-ads experience!