473,549 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display a box in "em" units?

I'm trying to figure out how to display a box that has a width in
"em" units. So far no luck. Below is some HTML that displays two
rows of 30 'm' characters in lowercase and uppercase, followed by
a 30em-wide table and a 30em-wide div block. I'm using HTML 4.01
Transitional doctype.

=============== =============== ==
<p>lines of 30 M:<br>
MMMMMMMMMMMMMMM MMMMMMMMMMMMMMM <br>
mmmmmmmmmmmmmmm mmmmmmmmmmmmmmm <br>
<table width="30em" border=1 cellspacing=0 cellpadding=0>
<tr><td>30em wide table</td></tr>
</table>
<div style="border: 1px solid black; width=30em; min-width=30em; float: left;">
30em wide rectangle
</div>
=============== =============== ==

The resulting table appears to be 30 pixels instead of 30em. It's
very narrow.

The div block is only as wide as the containing text. It's
certainly not 30 M characters wide.

What am I doing wrong? The example above works the same in IE and
Opera.

Also, which M width is used by the "em" units? Uppercase or
lowercase? These widths are different for larger font sizes.

-A
Apr 1 '06 #1
38 3760
ax**@spamcop.ne t (axlq) writes:
I'm using HTML 4.01 Transitional doctype.
Why not strict?
<table width="30em" border=1 cellspacing=0 cellpadding=0>
<table style="width: 30em" border=1 ...
Also, which M width is used by the "em" units? Uppercase or
lowercase? These widths are different for larger font sizes.


Neither - it's the width of the "em quad".

--
Chris
Apr 1 '06 #2
In article <87************ @dinopsis.dur.a c.uk>,
Chris Morris <c.********@dur ham.ac.uk> wrote:
ax**@spamcop.n et (axlq) writes:
I'm using HTML 4.01 Transitional doctype.


Why not strict?


Does it matter? Does the behavior of "em" units change between
transitional and strict?

-A
Apr 1 '06 #3
axlq wrote:
I'm using HTML 4.01 Transitional doctype.


Why not strict?


Does it matter? Does the behavior of "em" units change between
transitional and strict?

Yes.
No.

Transitional, as you might surmise from the term, was meant to allow a
gradual transition from pre-v4 HTML to v4. Implied in the name is
transition, temporary, for a little while, short time, placeholder, a
breather space. It was never intended for common, ongoing usage.
A more cogent reason for Strict is that browser rendering is more
uniform and predictable, especially IE.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Apr 2 '06 #4
Jim Moe <jm************ ***@sohnen-moe.com> writes:
A more cogent reason for Strict is that browser rendering is more
uniform and predictable, especially IE.


Pardon, 'especially IE'?

I suppose you actually mean doctype sniffing by 'strict'.

* IE < 6 doesn't do doctpe sniffing. Double your efforts.
* IE 6 in 'standards-compliant mode' does have lots of bugs that IE 6 (and
lower) otherwise does not sport. Quadripple you efforts.
* Client side or any inbetween proxy software can unexpectedly -- and
legally -- wave good-bye to 'standards-compliant mode', and you'll
never know; say hello to voodoo-programming.
* The MSDN excuse for documentation clearly states that
'standards-compliant mode' is *not* predictable.
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Apr 2 '06 #5
Tim
ax**@spamcop.ne t (axlq):
Also, which M width is used by the "em" units? Uppercase or lowercase?
These widths are different for larger font sizes.

Chris Morris: Neither - it's the width of the "em quad".


The *size* used for it. It also has height, and it's not necessarily
square.

For those not wanting to look up the em quad, broadly speaking it's the
space used for printing the capital M, including the spacing that goes
around it. Much the same as when you printed using blocks (individual
letters on a block), in ye olde printing machines, it refers to the entire
size of the block, not just the size of the letter on it.

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please destroy some files yourself.

Apr 2 '06 #6
In article <pa************ *************** @mail.localhost .invalid>,
Tim <se**********@o ptusnet.com.au> wrote:
[an 'em' is] the space used for printing the capital M, including
the spacing that goes around it.


Thanks, that's good to know.

-A
Apr 2 '06 #7
In article <pd************ ********@gigane ws.com>,
Jim Moe <jm************ ***@sohnen-moe.com> wrote:
axlq wrote:
I'm using HTML 4.01 Transitional doctype.

Why not strict?


Does it matter? Does the behavior of "em" units change between
transitional and strict?

... [in Strict,] browser rendering is more
uniform and predictable, especially IE.


Okay, so I've changed the doctype to strict. It validates. It
didn't make a difference in behavior. Here's a link:

http://sunbeam.rahul.net/~unicorn/boxtest.html

Now, would someone explain to me how to display a text-container
block 30 em wide? This seems like such a simple and trivial thing
but for some reason I'm failing to grasp a key concept here.

-A
Apr 2 '06 #8
On Sun, 2 Apr 2006 15:40:26 +0000 (UTC), ax**@spamcop.ne t (axlq) wrote:
Now, would someone explain to me how to display a text-container
block 30 em wide?


Replace
width=30em;
with
width:30em;

Apr 2 '06 #9
axlq wrote:

Now, would someone explain to me how to display a text-container
block 30 em wide? This seems like such a simple and trivial thing
but for some reason I'm failing to grasp a key concept here.
Reading the answers people give to your questions would be a good start.
Chris Morris gave you this advice:
<table style="width: 30em" border=1 ...


The use of ems is supported in CSS, but not in HTML. Your sample
specifies the width of the table as an HTML attribute, not as a CSS
property.

Furthermore, in your <div> you specified the CSS width property using
HTML-like notation (width=30em), which CSS didn't understand. it should
have been width:30em.

--
Jack.
Apr 2 '06 #10

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

Similar topics

6
2419
by: Xah Lee | last post by:
how to represent the unicode "em space" in regex? e.g. i want do something like this: fracture=re.split(r'\342371*\|\342371*',myline,re.U) Xah xah@xahlee.org ∑ http://xahlee.org/
0
7518
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...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
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. ...
1
7469
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...
0
6040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
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...
0
5087
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...
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.