Skip to main content
Inspiring
May 12, 2018
Answered

Why in CSS with an "italic" class the text becomes smaller?

  • May 12, 2018
  • 1 reply
  • 591 views

In a html-file I have paragraphs with text. I have a CSS-file, with some classes.I have set up "p" with:

p {   

   font-family:Verdana, sans-serif;

    font-size:0.833em; /* and so on*/

}

.italic {

    font-family:Verdana, sans-serif;

    font-size:0.833em;

    font-style:italic;

    font-weight:normal;

}

.rientro {

    margin-bottom:4px;

}

I have: <p class="rientro"><span class="italic">text,text</span></p>, the text is malles then the "normal" text, without italic, why?

    This topic has been closed for replies.
    Correct answer ALsp

    Because ems is a proportional measure. So...

    Based on your rules, elements assigned the italic class will have text 83% as big as their parent paragraph does. If you want italic to be the same size as the rest of the text, leave the font-size off.

    Font-size, by the way, need only be set on a single element, usually the body, with the need to further declare based on exceptions to the body rule.

    1 reply

    ALsp
    ALspCorrect answer
    Legend
    May 12, 2018

    Because ems is a proportional measure. So...

    Based on your rules, elements assigned the italic class will have text 83% as big as their parent paragraph does. If you want italic to be the same size as the rest of the text, leave the font-size off.

    Font-size, by the way, need only be set on a single element, usually the body, with the need to further declare based on exceptions to the body rule.

    pfudiAuthor
    Inspiring
    May 12, 2018

    First thank you very much for replay! It is realy helpfull!!

    I will look for to remove al font-size, because I have bold and so on in the CSS.

    Now the text have the same size like the text, it's wonderfull!!!

    Thank zou so much

    Have a nice Sunday

    pfudiAuthor
    Inspiring
    May 12, 2018

    It works on Dreamweaver very well, but on Sigil (for epub) it don't works, why?