CSS box borders

css

This is a CSS problem. I need to trim the white spaces from a div or list or paragraph.

-------------------------------------------
| This is my Text.                        |
-------------------------------------------

How to convert this div/list/paragraph (i.e. any box) to show like the following when it is needed?

--------------------
| This is my Text. |
--------------------

And the Vice-versa?

This should work regardless of the parent container.

Best Answer

You could change the style of the elements that contain "This is my Text" to display:inline and that should provide the desired effect.

It's worthy to note that without knowing the entire layout or rather just setting this as the default style may have unforeseen consequences (causing normally blocking elements to not block). A better solution would be to wrap the text in elements that would normally have this effect or apply specific classes to the normally blocking elements to differentiate them.