CSS CSS Basics Understanding Values and Units Percentages

Andrew Felix
Andrew Felix
1,517 Points

Is % (percentage unit) responsive?

I gave font-size : 150% to p element. It gave 24px (computed value) font-size initially for p element. When I resize the window to smaller size (small view port), The font-size for p element should get reduced in relation to the view port size right? size of the font for p element seems to be same as original. It is not responsive right?? Please help!

2 Answers

Tray Denney
PRO
Tray Denney
Pro Student 12,884 Points

Font-size percentages are not responsive in that way. They are responsive to the browser zoom/type settings. If you want to change the size of the text based on the window then you will need to use media queries or you can use viewport values: https://css-tricks.com/viewport-sized-typography/

Andrew Felix
Andrew Felix
1,517 Points

Thanks a lot for your immediate help Denney! The solution you provided and the article you mentioned are really great!

Because they are connected not to browser width and height but to the user agent stylesheet. These values are fixed.