views:

75

answers:

1

I have an html document that is included as an iframe in a toolbar. The document includes a single line of text.

I wish to limit the width of the document, so that it doesn't exceed a maximal width, but can occupy less if the text is short.

How can this be achieved?

If helpful, the document is actually a php document and I can use javascript.

A: 

If the maximum width is given in pixels, I’d style the inluded document via CSS:

body {
    max-width: 500px;
}

Note: this does not work in IE6, as it does not support the max-width property.

Apart from that, since you can use JavaScript, instead of using an iframe you could also fetch the HTML via AJAX and inject the document into the DOM—which should make for easier/better styling.

igor