Link to home
Start Free TrialLog in
Avatar of PACCAST-DEV
PACCAST-DEVFlag for United States of America

asked on

place a box (border) around text on html page

how do I create a box around a block of text in html?

I tried this but the borders overlap between lines of text:
<font style="border: 4px solid #0000FF;">
3) H.I.P. TO THE FOLLOWING SPECIFICATION: <br />
     &nbsp;&nbsp;&nbsp; a ) PER ... <br />
    &nbsp;&nbsp;&nbsp; b ) temp is: 1300 <br />
    &nbsp;&nbsp;&nbsp; c) temp2 is 1500 <br />

</font>
Avatar of PotentisFrog
PotentisFrog

Not sure if you mean a block of text, or an "inline" span of text. Anyway, you might try this if you want the entire block.

1. Entire block:
<div style="border:1px solid black">Your stuff here</div>

or
2. Inline:  
<span style="border:1px solid black">Your stuff here</span>
Avatar of PACCAST-DEV

ASKER

div method extends box beyond text to the end of the page,
span method has same problem as orignal html
please see pictuer

textbox.JPG
To use the div method, you can add in a fixed width to the inline style like so:
<div style="border:1px solid black; width:500px" >Your stuff here</div>
I would like the box to wrap around the text, not be the same static width no matter the width of the text and either extend way past it or force it into a box the size of the div tag...
It sounds like you want the <span> version then. Did you try that? It's "inline" meaning it only extends as wide as the text it surrounds.
Sorry, I see that you did try the span.  
ASKER CERTIFIED SOLUTION
Avatar of PotentisFrog
PotentisFrog

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi all,
this is an intranet app, IE will be the only browser.
I would like it to display similar to the div method (see picture) except the right border to extend only as far as the longest text, i.e. borders around the entire block of text. I am hoping to avoid the table method becase I am building the html in asp code and trying to keep it simple. My page is an aspx page that gets created dynaically, the text comes from a database, and I am adding the html formatting tags (the formatting is stored in the DB also) to it in code like below.

Private Sub FormatText(ByRef baseText As String, ByVal dr As SqlDataReader)
Dim fontText As String = "" 
Try
If dr("FormatBold") = True Then
baseText = baseText.Insert(0, "<b>")
baseText = baseText.Insert(baseText.Length, "</b>")
End If
' format the font tag
fontText = "<font color='" & dr("FormatColor") & "'"
If dr("FormatLargeFont") = True Then
fontText &= " Size='5' " 
End If
If dr("FormatBox") = True Then
fontText &= " Style = 'border: 4px solid #0000FF;'>"
Else
fontText &= ">" 
End If
baseText = baseText.Insert(0, fontText)
baseText = baseText.Insert(baseText.Length, "</font>")
If dr("FormatUnderline") = True Then
baseText = baseText.Insert(0, "<u>")
baseText = baseText.Insert(baseText.Length, "</u>")
End If
If dr("FormatItalicized") = True Then
baseText = baseText.Insert(0, "<i>")
baseText = baseText.Insert(baseText.Length, "</i>")
End If
Catch ex As Exception
End Try
End Sub
hello, anyone with any feedback given my last post?...
Appears this is not possible...
please close