Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i set to border to be as long as it needs to be?

Tags:

html

css

I have code like the below. Instead of having the box stretch all the way to the right how do i make it only as long as it needs to be?

<html><body>
<pre style="{border-style:solid;}">A Sentence</pre>
</body></html>
like image 926
user254492 Avatar asked Jan 20 '10 00:01

user254492


2 Answers

You could use

<pre style="display: inline; border-style: solid">

(the {} don't belong in the style block by the way)

That would render the element as an inline object that doesn't occupy full width anymore, but flows like normal text. However, that way, the next following element will follow right next to the pre, and you may have to add <br> line breaks.

like image 179
Pekka Avatar answered Oct 06 '22 00:10

Pekka


Using an inner element would be a simple approach:

<html><body>
<pre><span style="border-style:solid;">A Sentence</span></pre>
</body></html>
like image 32
Nick Craver Avatar answered Oct 06 '22 00:10

Nick Craver