The paragraph will fill th
This is not a bug, you don't need a fix in ECMAScript to solve this.
You have to think about the tree in which your content resides.
window
\- html
\- body
\- p
\- content
So, your content's width is determined by the CSS attributes on the p
element. So, as you will want the text to be as width as your browser's window is we can try to put its width to 100%; thus:
p { width: 100%; display: block; margin: 0px; padding: 0px; }
However, you will experience that this isn't working as you thought. This is however not a bug, but simply a misunderstanding of the standard. Let't have a look at what the standard has to tell us about setting a percentual width on an element, see the width property in the visual formatting model details:
Specifies a percentage width. The percentage is calculated with respect to the width of the generated box's containing block. If the containing block's width depends on this element's width, then the resulting layout is undefined in CSS 2.1.
Emphasis mine, this text says that it is calculated with respect to the width of the containing block. Looking back at our tree, p
is contained within body
. So, what's the width of our containing block?
We haven't defined that width yet, so it is taking on some value determined by the browser.
The solution here is to define the width of the body as well, which translates to adding 6 characters:
html, body, p { width: 100%; display: block; margin: 0px; padding: 0px; }
So, now your html
's width is 100% of your window's width, body
's width is 100% of your html
and your p
's width is 100% of your body
. this should get all the width's right.
The bottom line is to think about your DOM tree and check out the CSS standard...