Aravinth
Aravinth

Reputation: 363

Word Space Not Working in HTML page

Hi guys In my Html PAge...Im using white space between the words...and its not displaying correctly in Browser...Its fully Wrapped and Single white space is left between the words...wats the solution to Fix this...

Here is my code

<html>
   <head>
      <style type="text/css">
          th {word-wrap: break-word}
      </style>
   </head>
   <body>
     <h1>Sample</h1>
        <p>A paragraph.<th>Aravinth               Bike</th></p>
   </body>
</html> 

The Output is

A heading
A paragraph.Aravinth Bike

Upvotes: 0

Views: 3395

Answers (3)

Janak
Janak

Reputation: 5052

To explicitly add the space you can use &nbsp; [represents 1 single space].

A paragraph.Aravinth                      Bike

Here, i've added a few &nbsp;'s to have the space.

Upvotes: 0

Barmar
Barmar

Reputation: 780974

Use the style:

th { white-space: pre; }

Or replace each of the spaces with &nbsp;.

Note that your <th> tag is likely to be ignored by browsers. <th> has to be inside <tr>, which has to be inside <table>.

Upvotes: 3

TGH
TGH

Reputation: 39248

This is by design. White space is ignored by the browser. You are better off setting padding or margin using css

You can also use a pre tag which preserves white space formating.

Upvotes: 1

Related Questions