+3  A: 

You are not putting semicolons at the ends of the lines, which is required (except on the last line) for CSS to parse correctly.

Robusto
Or maybe someone who edited the TP lost that in the translation? If so, ignore my observation.
Robusto
Yes lost in translation - I'll add them back
+1  A: 

Beyond the semi-colon issue, the one important thing the pre tag does is set the CSS white-space property to "nowrap" (or "pre" I suppose, but that just confuses things), so it's working exactly as it should. If yo want to stop it from working like that, set "nowrap: normal;". However, that makes the pre element work like every other element instead of how it's intended to work, which might confuse other people working with you. Why not just use a div element? What are you trying to achieve?

Tom
Display some code.I dont want it to wrap, I want the yellow (#FFFFCC) box to have the dimensions of the text. If I set the float property this is what happens. As it is I get a fixed width box and the comments of the code overflow. Ugly. I don't want to use scrolling either.Any idea ?
Actually I set the white-space property to nowrap in dreamweaver and it displays nice, but in firefox (3.5) I see a huge line of text and the box has still fixed width. Same in ie6 but the box has the width of the line. Welcome to css I guess.Help
I set the white-space property to pre-wrap : in dreamweaver (CS3) the text still overflows but in ie6 I got what I wanted. In firefox the text wraps but no more overflows. Now is there a way to get the ie6 picture (due to some bug probably) over to ff ?
Do you have a url we can look at?
Tom
Uploaded images pz have a look :)
I'm with ricebowl: from what you've said, you can't do what you want with a purely CSS solution.
Tom
+1  A: 

If I'm reading your question correctly, you want to display code/text contained within a box, and that code cannot wrap (unless such wraps, or carriage-returns/line-feeds/etc are present in the code/text itself). You also want the containing element to increase its horizontal dimension in order to expand to the required width of the text/code?

So if your text had 20 characters as its longest line, your <pre> would be at least 20 characters in width, if the text had 200 characters for the longest line then it should stretch to accommodate the 200 characters?

If these assumptions are correct, then you can't -without javascript, at least- do what you want to do, since it would require setting the width of the parent based on the width of its child element. Unfortunately CSS cascades down the DOM, and in one-way only.

The best you could do, without JS, is to add:

overflow: scroll; /* or auto */

or:

overflow-x: scroll;

to your CSS, which would maintain the width of the <pre>, but allow for scrolling to allow for the longest lines to remain un-wrapped.

If I've misunderstood your question, please raise a comment, and I'll do what I can to address your question more usefully.

David Thomas
Thank you ! You read it correctly. So the behavior of ie is a bug ? Cause it is the only bug I know of worth reproducing. I am not for the overflow property - I need js to reproduce the ie bug ?
Any documentation (links) for the bug would be very useful btw.Thanks (also for the edits)
And an explanation as to why float:left does the job !? I will be experimenting with this and clear - maybe I 'll have it my way after all :)
I'm unsure as to why `float: left` does the job, it might be because `float` takes the element out of the document's flow and removes the constraint for the element to inherit its parents' width? But this is just a guess and I certainly can't back it up with evidence. If others can correct me I'd be interested to know.
David Thomas
I wrapped the sections of the readme in divs floated to the left and ` clear:both ` and it works exactly as I want in ff 3.5 and opera 10 - but now ie6 restricts the width of the divs considerably (?!) Any fix ?
Update your question (or, possibly, consider starting a new question if you feel it merits doing so) with where you're at now, and I'll have a proper look when I get a moment.
David Thomas
Updated - almost solved :)