How to remove extra space after subscript 2 in Internet Explorer - css

I am building a website that uses a subscript 2 a lot, as in H₂O. The ₂ is created with the HTML code ₂ rather than the tag.
Here's the problem, in Internet Explorer there is a large space after the ₂. How can I fix this with #css ?
Screenshot of site in IE9

This is a font problem. There is no perfect solution, because the page uses the SUBSCRIPT TWO character (which is fine in principle) – not with any HTML code but as such, as a UTF-8 encoded character (which is fine) and it uses the Open Sans font, which is a nice font but does not contain SUBSCRIPT TWO. This means that browsers will use some fallback font, and IE seems to use a font where the glyph for SUBSCRIPT TWO has a lot of space on the right of the graphic (you can see this by painting the character with the mouse; the fallback font in IE seems to be something like Batang in this case).
There are two ways to deal with this.
You can list down your preferred fallback fonts in the font-family declaration. In your CSS rule for body, instead of just font-family: 'Open Sans', you could use e.g.
font-family: 'Open Sans', 'Calibri', 'Arial Unicode MS', 'DejaVu Sans', 'FreeSans',
'Lucida Sans Unicode';
It’s difficult to say what you should put into the list and in which order, but the above should cover almost all browsing situations, with tolerable rendering results. There is still the problem that you would mix glyphs from different fonts, so the result won’t really be good. For optimal results, the subscript should come from the same font as other characters.
Another way is to use a different basic font instead of Open Sans. Among Google fonts, you might consider Source Sans Pro. It is a nice sans-serif font family, with many typefaces (with weights starting at 200), and it contains SUBSCRIPT TWO; you need to check the box “Latin Extended (latin-ext)” when selecting it at Google Web Fonts, otherwise SUBSCRIPT TWO won’t be included.

Related

Diacritics thicker than rest of the letters

I'm using Open Sans font from Google Fonts on one of my page, and altho I'm using almost the same style regarding the font as Google does, my diacritics are somewhat thicker than the rest of the letters:
(you can see the live version at www.cabsurf.com)
The only difference in my CSS is the way I declare the font family:
font-family: 'Open Sans', Helvetica, Arial, sans-serif;
But it will look the same even if I leave only Open Sans in the declaration.
I've placed the same text in Google Fonts page above (using inspect element in Chrome) and the text is rendered correctly on their side, so I know the font is ok.
Any idea what am I doing wrong ?
EDIT:
Using Chrome 27 / Firefox 22 on MacOS X 10.8.4
Google will use any sub-set of the font it wants. Did you make sure to check the correct boxes when you got the code for it?
When I append <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800,300&subse‌​t=latin,cyrillic-ext,cyrillic,latin-ext' rel='stylesheet' type='text/css'>to your <head>, all the characters look correct.
Just make sure to check whichever sub-sets you need so you don't get unnecessarily large files.

Embedded fonts B and I not working on safari 3.2

I have embedded fonts to my webpage and randomly in the divs i use font-style = italic and font-weight=700.
My #font-face rule is:
#font-face {
font-family: 'Arimo';
src: url('fonts/arimo_bold_italic.eot');
src: url('fonts/arimo_bold_italic.eot?#iefix') format('embedded-opentype'),url('fonts/arimo_bold_italic.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
Though the font-style and font-weight additions are working fine on all the browsers, it does not seem to work on Safari 3.2 giving weird results like the style and weight being applied only sometimes at random.
Any solution?
You are specifying the typeface as normal weight, regular (not italic). This is possible and often used to overcome some browser limitations, and it is also the way FontSquirrel uses in the CSS files it generates. But is has its implications.
In this case, font-family: Arimo alone produces bold italic Arimo, since this is how you have defined the name Arimo. To a browser, Arimo is just a normal-weight regular font, so if you ask, in CSS or indirectly e.g. via b or i markup, it to be used in bold face or italic, most browsers will use the font as such.
According to the CSS 2.1 font matching algorithm, when italic (or bold italic) is requested for, a regular face is not considered a match. This means that the browser should fall back to its default font, unless your rule specifies a secondary font. No browser actually does this: Safari produces “synthetic italic” by algorithmically slanting glyphs, whereas most other browsers just use the regular font (i.e., the font they regard as regular since it was declared that way). In CSS3, this is to be changed so that the behavior of most browsers becomes the norm.
So this is a messy business, and to avoid the mess, use one of these approaches:
a) Declare each font face as a family of its own, as regular and normal-weight, as you have done here, and do not apply font-weight values other than normal' orfont-stylevalues other thannormal` to text in such a font, directly or indirectly (note that many HTML elements produce italic or bold b default).
b) Declare each font face as a font in the family, with font-weight and font-style set in #font-face the logical way, and use the font family the normal way, declaring font-weight: bold when you want bold etc. This is how Google Web Fonts work, when hosted by Google.
P.S. It is odd that the `#font-face' rule does not mention a WOFF format file, which is the preferable format of downloadable fonts when a browser supports it. Generators normally produce it, too, and include it in the rule.

Same font renders differently across FF7 and Chrome

Screenshot: http://i.imgur.com/QVBGx.png
It is pretty evident that my site renders different on Chrome and FF7 on my Win7 machine
I am using this:
h1, h2 {font-family: "Lucida Grande", "Helvetica Neue", Arial; }
Does anybody can point me how can I even these diffs? I don't want fonts with different 'feelings' on each browser.
The font, Lucida Grande is installed in my Windows machine
EDIT:
font-weight: normal !important
doesn't work either
It looks like the two browsers are rendering it with a different weight.
I can think of two possibilities, though I don't know if either are correct.
You requested a bold font, but that font is not available in bold. One browser is just showing the regular, non-bold variant unchanged, whereas the other has processed it to look bold.
You requested a particular weight of font, say "bold" or "600" but the installed fonts do not precisely match that weighting. One browser is substituting an "extra-bold" variant of font, and the other a "regular-bold", or something of this nature.
If either of these is correct you could play around with the font-weight CSS property to try and alter it. But then that may affect substitution of whichever font is chosen in the case that it is viewed on a system with no Lucida Grande font at all.
Fonts will always render slightly different from one browser to another, but that was a bit more difference than usual. Probably because the headers have font-weight: bold; as default, and the font doesn't have a bold variation so the browsers create the bold style from the regular weight in different ways.
Anyway, you might want to use more common fonts. On my Windows 7 machine there is neither Lucida Grande nor Helvetica Neue, so it would render using Arial. Still, I have the additional fonts that come with both MS Office and Photoshop, so I have a lot more fonts installed than you can expect from a standard system.
Also, you should always specify a generic font as the last resort, in this case sans serif, otherwise it would render using the default font if none of the fonts are installed, which is something like Times Roman which has a completely different look. Perhaps also adding Helvetica, which is the closest equivalent of Arial on non-Windows systems.

Is it possible to force "font priority" in style sheets?

In various browsers, when a specific font is used (e.g. - Helvetica Neue), if that font is not found, the first font in the immediate family is used. So if I were to specify that Arial Narrow was the base font style for an element and my reader did not have this font, it would travel to the first available Arial font the system could find.
As an exercise, many sites like the Helvetica fonts (particularly the 'Neue' and 'Condensed' versions). They typically specify font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; believing that the browser will travel along this particular path and each font should be yummy with the first listed being the yummiest. However, Firefox/IE/Chrome (so I assume webkit browsers) all will fail to the find the specific Helvetica font required and move directly to the first font they encounter in the Helvetica family. One would think this would be Helvetica, but on my system it was defaulting to Helvetica 95 Black. I even tried renaming the font file to see if that was the cause, and no matter the filename, the result was that the page would default to Helvetica Black. I've found this to be the case with Arial as well.
So other than attempting to account for every single flavor of Helvetica, Arial, Verdana, Tahoma, ad infinitum, is there a way to force the browser to stop "guessing" at the family and accept only the exact font in question?
For starters, here's a description of the font matching algorithm as outlined in the CSS 2.1 specification (or CSS 3, if you prefer). This is a tricky issue though, as is evidenced by the disclaimer before the algorithm's details are outlined:
Because there is no accepted, universal taxonomy of font properties, matching of properties to font faces must be done carefully. The properties are matched in a well-defined order to insure that the results of this matching process are as consistent as possible across UAs (assuming that the same library of font faces is presented to each of them).
Also, note that you must enclose any font name containing whitespace with either single or double quotes, as per section 15.3.

All about choosing the right font for a website

I actually have right now two questions:
1) What font faces are preferred for a website? Right now I really like 'Segoe UI', but it's only available on newest Windows systems like Vista and 2008 Server. So I have defined a sequence:
font-family: 'Segoe UI', Tahoma, Arial, Helvetica, Sans-Serif;
I do not really like the look of all of them except for 'Segoe UI'. Any suggestions on what nice font could be used in addition to that? I also tried 'Trebuchet MS', it looks great on documents, but not really on a page.
2) Any way to specify with CSS different font sizes for each particular font-familiy? Like 'Segoe UI - 9px', Tahoma - 8px etc. This is probably not possible, but maybe there are some tricks?
I also know I will get lots of comments now to use relative font sizes, but I don't want that. I have some graphics in my design which are not stretchable. If the user or browser default lead to the font rendered with a varying size the design will quite soon fall apart. I prefer having design with font size limitations to not having design at all.
1) What font faces are preferred for a website?
See this page concerning safe web fonts.
2) Any way to specify different font sizes for each particular font-family through CSS?
Nope.
Soon, #font-face will be supported by all major browsers, and you'll be able to use any font you want on your website.
Until then, have a look at Cufón or sIFR.
Use the right typeface for your site. It's not as simple as saying "this is the best font for websites". Here are two quotes (read principles) from Robert Bringhurst's "The Elements of Typographic Style":
"Typography exists to honor content."
"Choose faces that suit the task as well as the subject."
On another note, unless a serif face really suits the website, sans-serif faces are more appropriate for digital media.
With regards to your second point, Phil Oye has recently released FontUnstack, a jQuery plugin which will tell you what font is being used for a given element. The element will be given a class (i.e. "set_in_gill_sans") through which you can apply specific styles for different typefaces.
Also, check out the font matrix (1.5 years old) and these well thought-out font-stacks.
1) What font faces are preferred for a website? Right now I really like
'Segoe UI', but it's only available on
newest Windows systems like Vista and
2008 Server. So I have defined a
sequence: font-family: 'Segoe UI',
Tahoma, Arial, Helvetica, Sans-Serif;
I do not really like the look of all
of them except for 'Segoe UI'. Any
suggestions on what nice font could be
used in addition to that? I also tried
'Trebuchet MS', it looks great on
documents, but not really on a page.
What font faces are preferred? This is a tough question. There are three main computing platforms that each have their own set of base fonts. Then, some software like Adobe Creative Suite, the Microsoft Office suite, or even software as simple as the Powerpoint 2007 viewer for XP install fonts for the user. There's lot of charts on the web that list commonly used fonts.
For a website, you're going to want to use legible fonts. Most of the screen fonts commonly used on the web are pretty legible. The fonts you mention for instance are good examples. The most legible on screen font is Verdana, although it's generally considered to be ugly. Arial is always a safe choice.
Just be careful with that Segoe UI declaration though: if a Windows XP user has that font, it probably won't be legible with anti aliasing disabled.
For headings, you can go custom and use techniques like sIFR and Cufon to replace the text with non-native system fonts.
A quick note on size: most sites tend to set a really small font size. 13 pixels really is the minimum for long texts (see relative readibility). A font with a small x-height like Times should only be used for headings or in a large enough size (e.g. 15+ pixels).
2) Any way to specify with CSS different font sizes for each
particular font-familiy? Like 'Segoe
UI - 9px', Tahoma - 8px etc. This is
probably not possible, but maybe there
are some tricks?
No, this is not possible. You can make assumptions about the browser and OS people are running via Javascript and thus make assumptions about the fonts they have installed, but it's a lot of work for a relatively small gain. I would advise against it.
Re. your font choice, I would consider usability to be a key requirement (unless you're going for a deliberately styled format).
Neilson made a study and found Verdana or Arial to be optimal choices in terms of legibility.
CSS3 will natively support downloadable fonts (you won't be promted to download, they will just work on the fly), so you will be able to use whatever typeface you want. We just have to wait for it a but since it will be available only in Firefox 3.5 and Opera 10.
You can also use classic fonts like: Arial/Helvetica, Verdana, Georgia, or even Times Roman for great visual impact. You just need to find the right font-size and contrast with other elements on the page.
Just personally, I like Verdana and Georgia, though they are only Mac/Windows-"safe". In your case perhaps it's best to select second-choice font which has the same metrics as your first choice.
Most major browsers already support #font-face so you can use any openly available font.
Google Web Fonts hosts some free fonts to choose from:
There are also paid websites like Typekit that will host paid fonts for you and let you buy them:

Resources