Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3306
  • Last Modified:

html space symbol/abreviation

What s the symbol/abreviation in html for a 1 charater space?
0
willa666
Asked:
willa666
  • 6
  • 5
  • 4
  • +5
2 Solutions
 
COBOLdinosaurCommented:
 

0
 
BatalfCommented:
Not sure what you mean, but   is the html entity for a 1 character space.

Example:

<h1>This is a word&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and more text</h1>
0
 
willa666Author Commented:
But when i use &nbsp; it loks like their are 5 spaces and if it is nested in a table row that is 10 Px high then it will acvchally show on the page as 20 px high.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
BatalfCommented:
Can you show an example?

When you're using it in a table, there could be some extra space added by the paddings and margins of your table.

Example:

Without margins and paddings:
<table border="1" cellpadding="0" cellspacing="0">
      <tr>
            <td>&nbsp;</td>
      </tr>
</table>

With margins and paddings:
<table border="1">
      <tr>
            <td>&nbsp;</td>
      </tr>
</table>
0
 
COBOLdinosaurCommented:
Yeah when you put the space in you now have text in the container so any CSS rules or html properties in effect will be activated. We need to see the code.

Cd&
0
 
DreamMasterCommented:
&nbsp; should not be used when you want to make exact heights, or widths for that matter, in table cells, use placeholder images instead if  that is what you want to acchieve.

What's a placeholder image?

A placeholder image is a picture of 1x1 pixel (more is allowed, doesn't really matter) that is transparent...you can give that any height or width you want and your table cells will not be higher or wider like with non-braking-spaces.
For example, if you want a table cell to be 10px high, use:

<td height=10><img src="spacer.gif" width="1" height="10"></td>

The height is 10 in the image can be left out, but I put it in to show you what I mean..

Regards,
Max.
0
 
lombardpCommented:
>&nbsp; should not be used when you want to make exact heights, or widths for that matter, in table cells, use placeholder >images instead if  that is what you want to acchieve

For what regards height, that is not totally true. You can use &nbsp;

The only thing you have to do, is to set a very small font size for that cell, try this example: background-color is only to highlight table cell.

For what regards width, place width attribute in style.


<html>
<head></head>
<body>

<table><tr style="background-color: red; height: 10px;">
   <td style="margin: 0px; padding: 0px; width: 10px; font-size: 1px;">&nbsp;</td>
</tr></table>

</body>
</html>
0
 
rdivilbissCommented:
>&nbsp; should not be used when you want to make exact heights

??? That is an odd statement.

>use placeholder images

That's plain bad advice.

CSS should be used for positioning per 1998 W3C recommendations.
0
 
chrissp26Commented:
If you need to achieve an exact space either use stylesheets to specify widths and heights for an element or use a blank gif 1 pixel x 1 pixel (transparent)  to achieve this.
0
 
DreamMasterCommented:
Carefull chrissp26, according to rdivilbiss the latter part of your comment is bad advice... ;)

Regards,
Max.
0
 
str_kaniCommented:
>>>>But when i use &nbsp; it loks like their are 5 spaces and if it is nested in a table row that is 10 Px high then it will acvchally show on the page as 20 px high.

If you want to show leave a 10px space, you SHOULD NOT put &nbsp; there. !!!


You can acheive the same by doing like this....

<TABLE style="table-layout:fixed">
<TR style="height:10px">
      <TD colspan="2"></TD>
</TR>
<TR>
      <TD>somehting here </TD>
      <TD> and here also</TD>
</TR>
</table>

This will surely help you :)
0
 
DreamMasterCommented:
Depends on how far back  your browser support should go str_kani...
0
 
str_kaniCommented:
This method works well for me. I am not sure what issue you are talking about. Could you please put more words.?
0
 
rdivilbissCommented:
DreamMaster,

It isn't my opinion as to what is or isn't "good advice."  Saying something that is contrary to W3C recommendations is not good advice but it may be the right solution to this problem.

You just don't want to make a blanket statement that it is the way to handle layout when there are better, standards compliant methods.

Table hacks for layout should have died with NS 4.

That does not mean the poster should rewite their whole page just because of 8 year old recommendations that developers continue to ignore, but if the person is making new pages they should be aware of the issues using depreciated and obsolete layout techniques.

Regards,
0
 
DreamMasterCommented:
str_kani, empty table cells have been a problem in many browsers. Internet Explorer renders them without a problem since, as far as I know, version 4.5 (correct me if I'm wrong, it's been some time) Netscape has had problems with it as far back as I can remember. As for FireFox and several others, I have never tried out what effect empty table cells have on those, as I always make sure they are filled.

rdivilbiss, I agree with you as for the W3C compatibilty...but you could have phrased your words a little gentler.. ;) It seemed as if you were attacking me when all I did was try and help. No harm done though...I can take it.. :)

Regards,
Max.
0
 
rdivilbissCommented:
Sorry, no offense meant.

At least it wasn't Cd&...he's really mean <smile>.
0
 
DreamMasterCommented:
Cd& and I know each other for some time...I know that lizard has some dirty tricks up his sleeve.. ;)
0
 
COBOLdinosaurCommented:
Sure jump on me when my back is turned.  Rod meet Max my former nemesis in HTML and WebDev.  ;^)

Cd&
0
 
COBOLdinosaurCommented:
Now all we have to do is get CJ (both of them) back.

Cd&
0
 
DreamMasterCommented:
Both the Cheeky and the asS one.. ;)
0
 
rdivilbissCommented:
What did I do?  I was taking a shower I have no idea who posted while I was gone.... 8-O ??
0
 
willa666Author Commented:
OK so a little recap class! :)

should i be using &nbsp; which personal i dont like as i cant control the size, or a table with a 1-3 spacing/cell border.

willa
0
 
lombardpCommented:
If you want to control height of table rows without text inside and the problem is that a &nbsp; is higher than 10px:
        reduce the font-size of the table cell (see my previous post), and you will solve the problem.

If you want some horizontal space between text and left/right border of a table cell:
        td { padding: 0px 10px 0px 10px; }


Do you need something like this?

<table border="0" cellspacing="0" cellpadding="0">
   <tr><th>Header #1</th><th>Header #1</th></tr>
   <tr><td style="height: 10px; font-size: 1px;">&nbsp;</td><td style="font-size: 1px;">&nbsp;</td></tr>
   <tr><td style="padding: 0px 10px 0px 10px;">Cell #1</td><td style="padding: 0px 10px 0px 10px;">Cell #1</td></tr>
</table>

0
 
rdivilbissCommented:
>should i be using &nbsp; which personal i dont like as i cant control the size, or a table with a 1-3 spacing/cell border.

As you see there is no other good alternative, but there are many ways to control row size, despite the space.

0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

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