Search code examples
htmlcssfont-size

When changing font size, is there an unit that changes proportional to all elements (h1 h2 h3 p)?


Is there a way to change the ratio on proportional way for the different elements or do i have to setup individually for all different elements?

i tried

HTML { font-size:150% }

But it will put ALL text elements (h1 h2 p etc.) in same font size. I want this to change proportional !!!!


Solution

  • You can use em for relatively applying font-size on them. For example:

    body {
        font-size:24px;
    }
    
    h1 {
        font-size:0.5em; // for 12px or relative to the body font 
    }