Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Small Caps doesn't work with Twitter Bootstrap on Chrome

I have this very simple markup

<h1>
    <a href="#">
        My Title
    </a>
</h1>

and this CSS

h1 {
   font-variant: small-caps;
}

Here it is rendered on a jsfiddle.

The issue comes from using Twitter Bootstrap. The text renders like it has no font-variant defined.

I'm sure that Bootstrap is the cause, since when you remove it, the text renders as expected. Any ideas or workaround for this?

I'm trying it on Chrome 26.0.1410.64

Bootstrap ON

Bootstrap ON

Bootstrap OFF

enter image description here

like image 203
Agustin Meriles Avatar asked May 16 '13 18:05

Agustin Meriles


People also ask

How do you do small-caps in HTML?

Using OpenTypeIf you use the value 'c2sc' (caps to small caps) instead of 'smcp' , capital letters will be rendered using small caps. This can be useful for uppercase initialisms, like WWW, when you wish to show them in small caps if possible.

What is font variant caps?

The font-variant-caps property controls the usage of alternate glyphs for capital letters. Show demo ❯ Default value: normal.

Which of the following CSS command gives the feature of small-caps?

Enables display of small capitals (OpenType feature: smcp ). Small-caps glyphs typically use the form of uppercase letters but are reduced to the size of lowercase letters. Enables display of small capitals for both upper and lowercase letters (OpenType features: c2sc , smcp ).


1 Answers

See this thread.

As strange as it is, the issue is actually Chrome, and the fact that you are putting the font-variant: small-caps; on a tag which resides inside an H# tag.

Apparently, Chrome is unable to honor small-caps on H# tags and their descendants at this time. Please take a look at this update to your fiddle to see what I mean.

You might have better luck altering your HTML to simply style a <span>, <p>, or <div> element to look like an <h1> element in this case - because Chrome will then honor your small-caps style.

Update:

Seeing the others' posts - I've noticed that the text-rendering: auto actually forces Chrome back into proper rendering. This update to the jsFiddle demonstrates this fix. Credit for the workaround to Martin.

like image 77
Troy Alford Avatar answered Sep 27 '22 16:09

Troy Alford