• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1427
  • Last Modified:

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>
0
PACCAST-DEV
Asked:
PACCAST-DEV
  • 6
  • 4
1 Solution
 
PotentisFrogCommented:
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>
0
 
PACCAST-DEVAuthor Commented:
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
0
 
downtapCommented:
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>
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
PACCAST-DEVAuthor Commented:
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...
0
 
PotentisFrogCommented:
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.
0
 
PotentisFrogCommented:
Sorry, I see that you did try the span.  
0
 
PotentisFrogCommented:
Given that you want the border around each line, you probably have to forego doing it all in a single font tag with br.  You either need to use a table or use a separate span for each line.  There are ways to finagle it to work as you have it (font tag with BRs) -- BUT you'll find that different browsers might display it differently and you'll spend a long time getting to work in all.
 
0
 
PACCAST-DEVAuthor Commented:
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
0
 
PACCAST-DEVAuthor Commented:
hello, anyone with any feedback given my last post?...
0
 
PACCAST-DEVAuthor Commented:
Appears this is not possible...
0
 
PACCAST-DEVAuthor Commented:
please close
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now