Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accents on numbers in HTML (like a ^ over 1)

I'm trying to find the best way to put circumflex accents ( ˆ = ˆ) on top of numbers (a musical notation) without resorting to images. Certain letters have equivalent HTML entities: ê = ê, Ô = Ô, etc., but numbers don't.

Here is what I'm currently using on my website:

<span style="position:relative;">1
   <span style="position:absolute; 
                left:0.1em; 
                bottom:0.2em; 
                font-size:1.1em;">
                &circ; 
   </span>  
</span>

It looks pretty good, but not perfect---because of slight differences in number shapes and browser rendering, something is bound to be a little off.

Does anyone have a more elegant solution for this?

Update:

The Combining Circumflex Accent &#770; or &#x302; produces different results on different browsers/platforms, most of which are not right (on my Mac, only Safari does it right).

According to this, proper display of a combining accent is dependent on both the font and the renderer. I'm using Times New Roman, Times, so it doesn't appear to be a workable option. I can't afford the hassle and inevitable ignoring of requiring a user to have a particular font.

I guess I'll have to stick with manually positioning the accent atop the note as above unless there's any other new answers. Thanks.

Update 2:

Embedding a free font with better diacritic support (especially Doulos SIL) seemed promising, but as of now (Nov 2009), Chrome does not support @font-face in CSS by default. Once it does, though, it will be great, since the other browsers are already on board. webfonts.info is the place for info on this.

like image 747
carillonator Avatar asked Nov 15 '09 21:11

carillonator


People also ask

How do you code accents in HTML?

Example 1: To input the circumflex â (&acirc;) in HTML, type in &acirc; or &#226; Exampe 2: To input circumflex ô (&ocirc;) in HTML, type in &ocirc;.

What is HTML &GT?

&gt; and &lt; is a character entity reference for the > and < character in HTML. It is not possible to use the less than (<) or greater than (>) signs in your file, because the browser will mix them with tags. for these difficulties you can use entity names( &gt; ) and entity numbers( &#60; ).

How do I get the accent over the e?

Unlike iOS, Android doesn't come preloaded with support for accented characters. However, there's an app for that—several of them, actually. Simply head to your app store and search for a “smart keyboard.” Choose whichever you like best, install it, then type accents, acute or otherwise, whenever you need.


3 Answers

U+0302 COMBINING CIRCUMFLEX ACCENT

Make one with character map or with the entity

 &#x302;

Stick one over anything you want by putting it after it:

e&#x302; A&#x302; 1&#x302; :)&#x302;

Becomes

ê Â 1̂ :)̂

...but it's not designed to go over the 1 or the smiley face. Notice how it moved up higher for the A but not for the 1 or the smiley face.

like image 135
Josh Lee Avatar answered Sep 21 '22 13:09

Josh Lee


Try the COMBINING CIRCUMFLEX ACCENT (U+0302) using &#770; or &#x302;:

1&#770;

Example:

like image 41
Gumbo Avatar answered Sep 20 '22 13:09

Gumbo


A lot will depend on whether or not the font your user is using supports this feature. Since you cannot embed fonts in a web page (without some potential legal trouble), your best bet is to try the above suggestions with different fonts to determine if the character your looking for is supported. Once you find a font, reference it in your CSS file and then inform the user that a specific font is required to correctly view your site.

Try using the following unicode index: http://www.fileformat.info/info/unicode/char/a.htm

You will need to know the name of the character you are trying to display. Once you've found it, the information page will tell you how to display the character using HTML character codes.

like image 34
JDB Avatar answered Sep 19 '22 13:09

JDB