user1752759
user1752759

Reputation: 635

Using Fractions On Websites

Is it possible to use any fraction symbol on a website, represented as ¼ rather than 1/4 for example?

From what I've gathered, these are the only ones I can use:

½

⅓ ⅔

¼ ¾

Is this right and why is that? The reason why I ask this is because I've done a Google web search and can't seem to locate any others ... eg. 2/4

Upvotes: 0

Views: 2329

Answers (5)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201778

There are several possibilities:

  • Use special character for fractions. Not possible for 2/4 for example, and problematic in font support for all but the three most common (vulgar) fractions you had found.
  • Use markup like <sub>2</sub>/<sup>4</sup>. Probably messes up your line spacing, and does not look particularly good.
  • Construct a fraction using some CSS for positioning and size control and using fraction slash character instead of the common slash. Rather awkward really, I would say.
  • Use OpenType <code>"frac"</code> feature. Rather limited support in browsers and especially in fonts.
  • MathJax, e.g. \(\frac{2}{4}\) or some more elaborated TeX code to produce a different style for fraction.
  • MathML. Verbose, and browser support to MathML inside HTML could be better.

These are explained more and illustrated in my page “Math in HTML (and CSS)”, section Fractions.

The choice thus depends on many factors. It also depends on the font quite a lot. I suggest that you test the different options using the font family declaration you intend to use. Despite the many alternatives, you might end up with using just the simple linear notation like 2/4.

Upvotes: 0

Jasen
Jasen

Reputation: 12432

As I undserstand HTML5 includes MathML which can represent any fraction you want.

While searching the unicode table I also found these: ⅑ ⅒ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞.

Upvotes: 1

mohammad mohsenipur
mohammad mohsenipur

Reputation: 3149

You can test http://www.mathjax.org/ it is a JavasScript library to make a Math Formula if this is what you want.

Upvotes: 3

poitroae
poitroae

Reputation: 21377

The image below displays all unicode-defined fraction symbols. Each of them is treated as one single character. You can use all of them freely, of course, but if you want more, e.g. 123/321, then you should look out for a library that can create fractions dynamically.

An option for doing so would be using LaTeX. There is another question (with very good answers) on how to do this.

enter image description here

Image from http://symbolcodes.tlt.psu.edu/bylanguage/mathchart.html#fractions

Upvotes: 2

fvu
fvu

Reputation: 32973

A web page is built up with text, and that text is encoded in a certain character set. The character set you select decides on which characters can be displayed. This also means that characters or symbols that don't exist in the character set cannot be displayed.

As shown in Michael's answer, Unicode defines symbols for a number of fractions. These can be displayed without using all kinds of tricks, for example server or client side generated small bitmaps showing the desired fraction, or as indicated by mohammad mohsenipur a Javascript library that transforms TeX or MathML.

Upvotes: 0

Related Questions