Vra

Een van my grootste tipografiese frustrasies oor HTML is die manier waarop dit MANGLES Siamese witspasie. Byvoorbeeld as ek:

<span>Following punctuation rules.  With two spaces after the period.  </span>

Een van die twee ruimtes na aanleiding van die tydperk sal oorweeg om onbelangrik witspasie wees en verwyder word. Ek kan natuurlik dwing die spasie beduidende te wees met:

<span>Following punctuation rules.&nbsp; With two spaces after the period.  </span>

maar dit irks net my te hê om dit te doen en ek gewoonlik nie die moeite doen. Is daar iemand daar buite outomaties voeg aansienlike witspasie in eksterne inhoud voorleggings wat bedoel is vir 'n webblad?

Was dit nuttig?

Oplossing

Vir jou spesifieke voorbeeld, daar is geen rede om te bekommer nie. Webblaaiers voer tipografiese lewering en plaas die korrekte hoeveelheid spasie tussen tydperke en alles karakter volg (en dit is anders, afhangende van die volgende karakter, volgens kerning reëls.)

As jy wil lyn breek,
is nie regtig 'n groot deal, is dit?


Nie seker wat is waardig van 'n downmod hier ... Jy moet nie dwing twee spasies na 'n tydperk, tensy jy 'n mono font. Vir proporsionele lettertipes, die rederer Kerns die regte hoeveelheid van die ruimte na 'n tydperk. Sien hier en hier vir gedetailleerde besprekings.

Ander wenke

As jy regtig wil jou wit ruimte te bewaar, probeer die eiendom css: wit-ruimte: pre;

Of jy kan net gebruik om 'n

 tag in jou opmaak. 

By the way, dis 'n goeie ding dat HTML blaaier ignoreer wit spasie in die algemeen, dit stel ons in staat om duidelik geformateer bronkode het, sonder dat die uitset.

Dit kan nie baie elegant, maar ek aansoek CSS om 'n

 tag. 

Daar is altyd die "wit-ruimte" CSS kenmerk, maar dit kan 'n bietjie treffer en Mej wees.

Neem 'n blik op die pre tag . Dit mag dalk te doen wat jy wil.

You can use a styled pre block to preserve whitespace. Most WYSIWYG editors also insert &nbsp; for you...

Overall, it's good that the browser ignores whitespace. Just view the source on this website for yourself and imagine how crazy the site would look if every space was displayed.

You'd better use white-space: pre-wrap than white-space: pre or &nbsp; With your example, the latter solutions can start a new line on "rules.&nbsp;" just because your non-breakable space hit the end of the line.

The PRE tag can be a valid solution, depending on your needs. However, if you are trying to use the 2 space rule in sentences throughout your site, you'll soon find that the other characters the PRE tag preserves are the line feed/carriage returns (or lack of) will muck up any styling you try to do.

In general, I tend to ignore the "2 spaces after a sentence" rule, or if you're a stickler for it, I'd stick with the &nbsp;, but you'll occasionally run into the issue Nicolas stated.

There is a page regarding this topic on webtypography.net. That site has many other interesting things about creating text for the web from the point of view of typography, things that web page designers often don't even think about. It's worth reading.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top