What can I use to substitute    in HTML?

2020-05-31 17:00发布

问题:

   is ugly, I think.

回答1:

Margin and/or Padding. (css properties), like so:

<p style='padding-left : 10px'>Hello</p>

(It's worth noting that it's generally considered bad-practice to put an inline style like that; you typically declare a selector in an external css file and set the class/whatever appropriately.)



回答2:

In CSS try:

white-space:nowrap;


回答3:

In CSS, Add

pre{
  white-space: pre-wrap;
  white-space: -moz-pre-wrap !important;
  white-space: -pre-wrap;
  white-space: -o-pre-wrap;
}
<pre>
    is not ugly anymore
</pre>


回答4:

I had this problem when I realised I will have empty tags. I didn't want to set a fixed height and it was to late to change the html. I wanted to add a space in the css, the substitute for &nbsp, so I added the space before the element, using :before (it needs to be specified via unicode).

p:before {
    content: "\00a0";
}

Hope this solution helps someone. The solution with padding didn't work for my problem.



回答5:

&#160; is alternative but it's also ugly

Beautiful solution is available in css.

If u need space at start of paragraph the u can use

p {text-indent: 10px; }

If u need spacing between word use like this

H2 { word-spacing: 3pt }

see here for more options http://www.hypergurl.com/csstutorial7.html

You can give these style to html by inline, external and from in-page(<head>....</head>)



回答6:

How about the letter-spacing and/or word-spacing CSS properties?



回答7:

You should use margin or padding properties with your elements to adjust whitespace.



回答8:

I used a span between two buttons.

<span style="margin-left:70px;"></span>

It spaced everything just where I needed it. I tried creating a "spacer" div, but that pushed one of the buttons below the other. I think that was because I was using a margin-bottom:30px; in the div.



回答9:

You need to use:

&nbsp;  non-breaking space: ' '
&emsp;  em space: ' '
&ensp;  en space: ' '
&thinsp;    thin space: ' '

SIX-PER-EM SPACE

<p>I will display &#8198;</p>
<p>I will display &#x2006;</p>

EN QUAD space example

<p>I will display &#8192;tt</p>
<p>I will display &#x2000;tt</p>

EM QUAD

<p>I will display &#8193;tt</p>
<p>I will display &#x2001;tt</p>

Table

Char    Dec Hex Entity  Name
    8192    2000        EN QUAD
    8193    2001        EM QUAD
    8194    2002    &ensp;  EN SPACE
    8195    2003    &emsp;  EM SPACE
    8196    2004        THREE-PER-EM SPACE
    8197    2005        FOUR-PER-EM SPACE
    8198    2006        SIX-PER-EM SPACE
    8199    2007        FIGURE SPACE
    8200    2008        PUNCTUATION SPACE
    8201    2009    &thinsp;    THIN SPACE
    8202    200A        HAIR SPACE
​   8203    200B        ZERO WIDTH SPACE

Basically you can replace 4 space with  

&emsp; == &nbsp;&nbsp;&nbsp;&nbsp;