473,836 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

&ensp in a monospaced font

Hi,

I am trying to output some html in monospaced font, and I want spaces to
take up the same width as any other character. i thought this would be easy
for monospaced fonts - surely   and   would both be the same
width?

unfortunately not -   is narrower than other characters and   is
wider :-(

so how do i generate a sequence of normal width spaces?

I can't use the <pretag because there is HTML markup in the output - it's
not only plain text

Andy
Feb 29 '08
59 7753
C A Upsdell wrote:
>
Something I have done on occasion is user '0' characters where I want
spaces, but with the colour the same as the background, so they look
like spaces.
I bet it sounds great in a screen reader. :-\

--
Berg
Mar 1 '08 #11
Bergamot wrote:
C A Upsdell wrote:
>Something I have done on occasion is user '0' characters where I want
spaces, but with the colour the same as the background, so they look
like spaces.

I bet it sounds great in a screen reader. :-\
Bad, very bad idea...'zero zero zero zero one two three'...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Mar 1 '08 #12
Els wrote:
Bergamot wrote:
>Why don't you just let the user decide what's most readable in a
monospace font?

By your logic, we shouldn't add any background or text colour either,
By your logic, we should set absolute font sizes to go with those fonts.
as the user can set that themselves too - what if your webpage is
black on white, while they would have preferred red on blue?
Now we're getting carried away. :)

Don't you get tired of every other web page insisting you use Arial or
Verdana or whatever? Why don't more authors just use the generic
families instead of over specifying everything?

We all make such a big deal about user controlled font sizes, but
default fonts are pretty much totally ignored. :(

--
Berg
Mar 1 '08 #13
Els
Bergamot wrote:
Els wrote:
>Bergamot wrote:
>>Why don't you just let the user decide what's most readable in a
monospace font?

By your logic, we shouldn't add any background or text colour either,

By your logic, we should set absolute font sizes to go with those fonts.
Nope, I'd set relative font-sizes that I think go with the rest of the
page and the purpose, and the user can still resize them, *and* force
their own user stylesheet over mine :-)
>as the user can set that themselves too - what if your webpage is
black on white, while they would have preferred red on blue?

Now we're getting carried away. :)
Really :-)
Don't you get tired of every other web page insisting you use Arial or
Verdana or whatever? Why don't more authors just use the generic
families instead of over specifying everything?
No, I don't get tired of that at all.
Have a look at these pages. Each of them please:
http://www.jasonsantamaria.com/
http://mezzoblue.com/
http://molly.com/
http://mappingtheweb.com/

See how each has a different font?
If you have them on your system, you should have seen Georgia, Lucida
Grande, Verdana and Trebuchet MS.

I'd get tired of seeing my own preferred font on every webpage while I
could be looking at diversity in typography.

And I don't get your "insisting we use Arial or Verdana or whatever".
They don't insist, they suggest. If you really want to have your
internet pages all in Verdana, just write your own stylesheet.
We all make such a big deal about user controlled font sizes, but
default fonts are pretty much totally ignored. :(
Which is a good thing :-)

--
Els http://locusmeus.com/
Mar 1 '08 #14
ok maybe I didn't make myself clear

i am using a monospaced font. on one line of the output i have
'abcde'; on the next line I have 'a' followed by 3 spaces followed by
'e'

I want the 'e' in the second line to appear underneath the 'e' in the
first line

if I use a normal space, the 3 spaces are collapsed into one; if I use
an m-width or n-width space, the spaces aren't the same width as
letters; if I use a non-breaking space, this stops the line breaking
(which is not the behaviour I want)

however, you (ant other posters) are right - I didn't realise you can
put other html codes inside a <preblock - so that looks like the
best option to me

Andy
On 29 Feb, 17:36, "Jukka K. Korpela" <jkorp...@cs.tu t.fiwrote:
Scripsit Andy Fish:
I am trying to output some html in monospaced font,

Do you mean you wish to present HTML markup visibly or audibly on the
page? Then a monospace font would normally be a good idea. I would
suggest using <codemarkup together with a style sheet like
code { font-family: Consolas, "Courier New"; }
to reduce the risk that some poor default monospace font is used.
and I want spaces
to take up the same width as any other character.

A normal space, as well as a no-break space, has the same width as other
characters, when the font is monospace
i thought this
would be easy for monospaced fonts - surely &ensp; and &emsp; would
both be the same width?

What? Why would you use specific-width space characters (which are
poorly supported in fonts) _and_ ask them to have the same width as
other characters? Why would you use them at all?
so how do i generate a sequence of normal width spaces?

By using the SPACE character U+0020 as everyone else.
I can't use the <pretag because there is HTML markup in the output
- it's not only plain text

You have misunderstood the meaning of <pre>, and what else?

The real problem is probably very different from the picture we've got
so far. To avoid wasting more of everyone's time, post the URL.

--
Jukka K. Korpela ("Yucca")http://www.cs.tut.fi/~jkorpela/
Mar 3 '08 #15
Scripsit John Hosking:
aj****@blueyond er.co.uk wrote:
- -
>i am using a monospaced font. on one line of the output i have
'abcde'; on the next line I have 'a' followed by 3 spaces followed by
'e'

I want the 'e' in the second line to appear underneath the 'e' in the
first line

Much clearer.
It's still not evident what the problem is. As usual, a URL would
have...
>if I use a normal space, the 3 spaces are collapsed into one; if I
use an m-width or n-width space, the spaces aren't the same width as
letters; if I use a non-breaking space, this stops the line breaking
(which is not the behaviour I want)

Even clearer.
Not to me, really. A few clarifications:

1) There is no "m-width" and "n-width" space. The width of an EM SPACE
equals the font size, by definition, and the width of an EN SPACE is
half of that. Their relationship to the widths of the letters "m" and
"n" is unspecified.

2) Normal spaces do collapse. This can be prevented in different ways,
but not in any evident way in inline text. (white-space: pre-wrap in CSS
would do this, but regarding browser support, "D'Oh!")

3) Whether em spaces, en spaces, or no-break spaces collapse is
explicitly declared unspecified in HTML specifications. In practice they
don't, but if IE 8 or Firefox 4 starts collapsing them, you can only
blame yourself if you relied on their not being collapsed.

4) The no-break space should prevent line breaks before and after. There
are some flaws in this area in browsers when a no-break space is
preceded or followed by a normal space.

But why would it be a _problem_ that line breaks are prevented, if you
want a specific placement of characters? To me, it seems like a
necessary part of a _solution_.
Then how about: <p>abcde</p><p>a&nbsp; &nbsp;e</p?
Since this was said to be computer output, markup like

<pre><samp>abcd e
a e</samp></pre>

would appear to be adequate. If this won't do, the OP should explain why
not.
That should give you both the spacing and a possible break. I believe
you'd get the same effect (but with two break possibilities) if you
did: <p>abcde</p><p>a &nbsp; e</p. (Not tested in all browsers.)
By the specifications, "a &nbsp; e" should have one break possibility
only, after the second space. Some browsers get this wrong. But I don't
see a reason for using such an approach.
It's only consecutive spaces that get collapsed.
As I mentioned above, no-break spaces may or may participate in the
collapse party. Currently they don't, but you have been warned:

"This specification does not indicate the behavior, rendering or
otherwise, of space characters other than those explicitly identified
here as white space characters [i.e. space, tab, form feed, zero-width
space]. For this reason, authors should use appropriate elements and
styles to achieve visual formatting effects that involve white space,
rather than space characters."
http://www.w3.org/TR/REC-html40/struct/text.html#h-9.1

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Mar 3 '08 #16
Jukka K. Korpela wrote:
>
3) Whether em spaces, en spaces, or no-break spaces collapse is
explicitly declared unspecified in HTML specifications. In practice they
don't, but if IE 8 or Firefox 4 starts collapsing them, you can only
blame yourself if you relied on their not being collapsed.
Except for the few white space characters for which collapsing is
specifically required, whether *any* character collapses is unspecified.
Yet I'm not going to worry that some day a new browser version will
display "bookkeeper " as "bokeper". I think it's taken for granted that
characters not arbitrarily collapsing with each other is the norm, and
only situations where they do collapse need to be articulated explicitly.
Mar 3 '08 #17
mrcakey wrote:
Both my alma mater and my erstwhile employer mandated the use of two spaces
after a full stop. You'll also see it in many books and magazines.
Old typewrite habits must be hard to break! Like folks who hit TAB to
lead off paragraphs...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Mar 3 '08 #18
Scripsit Harlan Messinger:
Except for the few white space characters for which collapsing is
specifically required, whether *any* character collapses is
unspecified.
That's nonsense and you know that.
Yet I'm not going to worry that some day a new browser
version will display "bookkeeper " as "bokeper".
Or as "fhjidsgyuh98er swygt98". This has nothing to do with whitespace
handling. Read the statement in the spec I mentioned. Its intent is not
hard to see.

The point is that space characters cannot be expected to result in any
specific amount of spacing, despite the fact that some of them are
defined as "fixed-width" spaces in character code standards (and
no-break space isn't, by the way, and it's the one we are usually
talking about in this context).

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Mar 3 '08 #19
On 2008-03-03, Jukka K. Korpela <jk******@cs.tu t.fiwrote:
[...]
3) Whether em spaces, en spaces, or no-break spaces collapse is
explicitly declared unspecified in HTML specifications. In practice they
don't, but if IE 8 or Firefox 4 starts collapsing them, you can only
blame yourself if you relied on their not being collapsed.
CSS specifications (CSS 2.1, 16.6.1) do say that the only things that
get collapsed are U+0009, U+000D, U+000A and U+0020. That is to say,
TAB, CR, LF and ordinary space.

The stuff between tags is thought of as anonymous inline elements so
this does cover everything.
Mar 3 '08 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1570
by: Mark | last post by:
I'm just after a bit of wisdom here. If I specify something like body { font-size: 1em; } is this really the same as body { font-size: 100%; } ?
3
4527
by: Joseph Gruber | last post by:
Hi all -- I have two questions. First, I'm adding a control to my form at runtime and the control/form seems to ignore the anchor property of the runtime control. Any idea how I can get a runtime control to anchor properly? Second -- the program I'm writting is supposed to look like a dos application (long story). When the application is "Normal" aka a small window then everything looks great. But when I resize the window to...
0
9827
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10862
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10607
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10262
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6986
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5838
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4468
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.