In response to Mark Pilgrim’s “Pushing 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!"
3 Responses to Visual Semantics