Dougal Campbell's geek ramblings

WordPress, web development, and world domination.

Visual Semantics

In response to Mark Pilgrim’sPushing the envelope” post, Hans Nowak complains that sometimes semantically correct HTML elements don’t “look good”. So, he tends to use <pre> instead of <code> to designate code fragments in web pages.

The answer, of course, is to just use CSS to make <code> act more like <pre>. Here’s my CSS:


code {
white-space: pre;
}

And here’s how it renders Hans’ code fragment:


def f(x, y):
if x > y:
print "foo!"
else:
print "bar!"

About Dougal Campbell

Dougal is a web developer, and a "Developer Emeritus" for the WordPress platform. When he's not coding PHP, Perl, CSS, JavaScript, or whatnot, he spends time with his wife, three children, a dog, and a cat in their Atlanta area home.
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

3 Responses to Visual Semantics

Leave a Reply

%d bloggers like this: