Jump to content

Is There A Short Way To Display Fractions In Html?


Robai

Recommended Posts

As far I know there are only three fractions:1/4, 1/2 and 3/4(using ¼, ½, ¾)Even those aren't displayed as they usually are displayed in math books.So, the question is how to display them right?And I mean any fraction:2/5, 11/13, etc.Any suggestions?BTW, it would be a really nice thing if there would be a way to display any LaTeX symbol in HTML. There are some converters from LaTeX to HTML, but I want to understand how to do it myself. And of course I mean converting not to pictures, but to HTML code (if it is possible at all).

Link to comment
Share on other sites

There aren't entities for all the other fractions because there aren't more unicode characters assigned to it.You could do something like this:

<sup>2</sup>/<sub>11</sub>

or use an image.For things like square roots and other more complex things the only thing I know of is MathML and there isn't a lot of support for that yet.

Link to comment
Share on other sites

If you are running your web page using ASP or PHP you could develop a small re-useable function that you just send through the two numbers in the fraction and then have it format them like above. I think that you will probably also be able to do the same using JavaScript on a static page to include the relevant SUB and SUP details.

Link to comment
Share on other sites

Sorry, somehow my whole post gone. So I will repeat it again.Thank you for replies.1. Similar to your suggestion, but a bit better, which I found here, is this:

<sup>2</sup>⁄<sub>11</sub>

2. A very good discussion about the fraction problem (and other math symbols problem in HTML) I found here. It proved that there is no simple solution in displaying math symbols in HTML.3. Here I found a way to display fractions inline. It really works in IE (at least in v6.0), but it doesn't work on FireFox, so this isn't a solution.4.I have installed MathML (and Editor from here), still not sure how to use it, but I already got some promising results. But only some things works in IE and some other things in FireFox.Anyway, this isn't a solution I was looking for, because MathML requires additional installation for user, which isn't the best thing at all.5.The last option is to make all those things myself (with JavaScript or PHP). Actually this is the only option for me.(maybe I will use 1. solution if I have no more time)But it is still hard to believe that there is no simple way to display fractions in HTML (inline).

Link to comment
Share on other sites

  • 11 years later...

Writing fraction in html is quite tricky. My site fraction calculator always display fractions in html format. The trick is to use table to display fraction. I will share here my html code. Here is my code to display 1/2 in html format.
<table><tbody><tr><td style="border-top:0px;border-left:0px;border-right:0px;border-bottom:1px solid #333;padding:0px;font-size:0.7em;text-align:center;vertical-align: bottom;padding:0px;">1</td></tr><tr><td style="font-size:0.7em;text-align:center;border:0px;vertical-align:top;padding:0px;">2</td></tr></tbody></table>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...