The best resources for developers

How do I know which font has been used in Web page?

 * Get the font used for a given element
 * @argument {HTMLElement} the element to check font for
 * @returns {string} The name of the used font or null if font could not be detected
function getFontForElement(ele) {
    if (ele.currentStyle) { // sort of, but not really, works in IE
        return ele.currentStyle["fontFamily"];
    } else if (document.defaultView) { // works in Opera and FF
        return document.defaultView.getComputedStyle(ele,null).getPropertyValue("font-family");
    } else {
        return null;
#fonttester {
    font-family: sans-serif, arial, helvetica;

Tags: html javascript css fonts

Source: By Pat as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 4.0

Related code-snippets: