Archives

Archive for December, 2010

Dec 9th

Styling pre and code HTML tags

2010
No comments | 1396 views

Styling <pre> and <code> tags can be cumbersome at times, especially when you use them for displaying content with arbitrary line lengths.

Source code of any kind and language is a good example here as it may contain overly long lines. Wrapping them inside <pre> or <code> tags has the potential of "blowing up" your page layout, because the browser will normally not reformat the content of a <pre> or <code> tag (pre stands for preformatted). This is especially annoying in forums or blogs because it will force readers to scroll the entire page horizontally and will generally look fugly.

Nevertheless, code blocks are important for many types of content - posting code examples, log files or anything else that contains pre-formatted textual data and almost any forum, blog or CMS allows for special formatting of code blocks.

Obviously, it is desirable to find a way to avoid these layout problems and there are basically 2 possible solutions:

Read more...

1 Like Like
Tags: ,