Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alternatives to pre 1

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
is there anyway to show text "as is" besides pre? any style that can be applied to a div or span perhaps?

[conehead]
 
TheConeHead-

While the width attribute is deprecated, you can get around it like this:

[tt]
<pre style="width:100px; word-wrap: break-word;">
This is
preformatted text.
It preserves both spaces
and line breaks.
</pre>
[/tt]

Note: I'm not sure if the word-wrap style works in all browsers. I know it does in IE.

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
hmmm... seem to still have issues... the width works but the pre is pushing out my table out as if it had no width to it...

again, any other options than pre for formatting text as is...

hate the pre...

[conehead]
 
Well, you could use the [tt]&nbsp;[/tt] in place of the space, and [tt]<br>[/tt] in place of the hard-return.

Do you have a URL?

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
no I don't... No - That's the point, I do not want to hard code stuff in - the text is coming from a SQL DB and I want to just use it as is....

[conehead]
 
What is the width of your table?

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
100% of what? If the width of your table is 100% of another table that is only 50px, and your <pre> tag has a style with the width set to 100px as per my example, then yes, it will push it out. Could you post the relevant section of your code?

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
No - it's just 100% of the screen....

Code:
<table cellspacing="0" cellpadding="3" border="0" bgcolor="#000080" width="100%">
		<tr bgcolor="#b0c4de">
			<td style="font-size: 14px;"><b><%=cat2("title")%>:</b> <%=rs("title")%></td>
		</tr>
		<tr bgcolor="#f5f5f5">
			<td>
				<p class="little">Last update: <%=rs("updated")%><br>Author: <%=rs("author")%></p>
<pre style="width:750; word-wrap: break-word;"><%=answer("answer")%></pre>
</td>
</tr>
</table>

[conehead]
 
Try the white-space attribute.
Code:
.pre {
  white-space: pre;
  font-family: courier, monospace;
}

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top