JoHa
JoHa

Reputation: 2039

How to NOT render the TAB character in HTML

I coded using Notepad++. Sometimes, when I echoed, I used to use the regular keyboard TAB to make the code look better in Notepad++. It was all fine till I used some CSS styling for word wrapping (to fix a problem for Mozilla Firefox):

td{
word-wrap: break-word;
white-space: -o-pre-wrap;
white-space: -moz-pre-wrap;
white-space: pre-wrap;
white-space: -pre-wrap;
}

This should be applied to all my "td" elements. So, what happened is these tabs that I had in Notepad++ are not being rendered as tabs on the page! Screwing up the design.

I don't want to just go replace-all tabs in the PHP files; won't be able to debug the code then!

Any solution? Any CSS styling that would remove or ignore rendering the TABs somehow?

Help! Thanks!

Upvotes: 2

Views: 717

Answers (1)

Dmitry Negoda
Dmitry Negoda

Reputation: 3189

Remove the "white-space" properties. Just the "word-wrap: break-word;" will work fine in all browsers. + enclose your text in div element with fixed width if you want your words to wrap.

Example:

<html><head>
<style>
td{
word-wrap: break-word;
}
</style></head>
<body>
<table width="120" style="width:120px"><tr><td>
<div style="width:120px">
    prevedasdasdasdasdasdasdasdasdadasdasdadasdad
        medved
</div>
</td></tr></table>

Upvotes: 4

Related Questions