P
P
p71612012-07-12 15:44:08
css
p7161, 2012-07-12 15:44:08

Arial font width in different browsers. With what it is connected, how to fight?

There is a code.
css

 .block {
padding:20px;
background:red;
float:left;
font-family:Arial;
font-size:14px;
}


HTML
<div class="block">
текст текст
</div>


As a result, we get a red block. How it looks in different browsers:
image

Question! How to deal with the extra two pixels in the width of the block (there may be more or less of them, depending on the length of the text). I understand the problem in rendering fonts in different browsers. Fixed width for .block is not suggested.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dom1n1k, 2012-07-12
@p7161

If “do not offer to fix the width”, then practically nothing.
The fact that fonts render differently on different operating systems is a known fact and nothing can be done about it.
If block sizes up to a pixel are critical for you, then you need to manage them (block sizes) directly. And if you control them indirectly (through text sizes), errors are inevitable.
If the context of the task were known, then perhaps it would be possible to suggest some half-hearted solutions-crutches. But in this setting, no way.

A
Alexander Borisovich, 2012-07-12
@Alexufo

so it will always be. Do not bother and it is worth looking for universal options

A
Alexey, 2012-07-12
@alexxxst

Fonts in pixels... however...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question