Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p tag to dynamic text width

Tags:

css

How can I make a <p> tag expand so that it is the right size for the content that will fill it. Just giving it padding does not seem to do that. And when I omit the width property, it expands to fill the entire width of its parent <td>. It has to be all inlined styles since it's email.

<p style="font-family:'helvetica', 'arial', 'sans-serif'; font-size:11pt; padding:7px 5px 5px 7px; background-color:#dddddd;">
    Purchase order {$sector_value['sector_info']['purchase_order']}
</p>
like image 220
1252748 Avatar asked Nov 26 '12 03:11

1252748


People also ask

How do you change the width of a P tag?

HTML paragraph width Forgive width to <p> tag you need to use CSS style width property. The width property sets the width of a paragraph element. width: auto|value|initial|inherit; Example: setting width 40px in HTML P tag, if the text is more then it will break to the next line.

How do I change the width of text in CSS?

The width property in CSS is used to set the width to the text, images. The width can be assign to the text and images in the form of pixels(px), percentage(%), centimetre(cm) etc. The width property does not contain padding, borders, or margins. The width property is overridden by the min-width & max-width properties.

How do you change the width of text in HTML?

1. Set width in HTML. In HTML, you can use the width attribute to set the width of an element. Alternatively, you can also use the size attribute to define the width of the <input> .

How do I make div width as content?

Using inline-block property: Use display: inline-block property to set a div size according to its content.


1 Answers

Just add display:inline-block to the paragraph! :)

http://jsfiddle.net/SZSFE

like image 128
Nathanael Avatar answered Sep 21 '22 13:09

Nathanael