Home > Enterprise >  changing Font size in html style attribute
changing Font size in html style attribute

Time:09-11

difference between both and why we use the % symbol and what does it means?

<p style="font-size:160%;">This is a paragraph.</p>

<p>This is a paragraph.</p>

CodePudding user response:

The first one has the style attribute (CSS) of font-size:160% it sets the font-size property to 160%. % is a relative CSS unit, it will set the font size to 160 percentage of the parent element.

<div style="font-size:24px;">
  <p style="font-size:160%;">This is a paragraph with 160% of the font size of parent div</p>
  <p>This is a paragraph with the font size of the parent div</p>
</div>

CodePudding user response:

Example:

This means that in the example below, the second div will be 50% of its parent, which will shrink to 30% of the page width. This is because the parent of the first div, the second div, is 60% of the page width.

<div>
    Birinci Div
    <div>İkinci Div</div>
</div>
 
<style>
 
div {
    width: 40%;
    border:3px solid red;
    padding:1px;
}
div div {
    width: 50%;
}
 
</style>
  • Related