Home
CSS
RWD Media Queries
Tryit: Change font size on different screen sizes
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> div.example { background-color: lightgrey; padding: 20px; } @media screen and (min-width: 600px) { div.example { font-size: 80px; } } @media screen and (max-width: 600px) { div.example { font-size: 30px; } } </style> </head> <body> <h2>Change the font size of an element on different screen sizes</h2> <div class="example">Example DIV.</div> <p>When the browser's width is 600px wide or less, set the font-size of DIV to 30px. When it is 601px or wider, set the font-size to 80px. Resize the browser window to see the effect.</p> </body> </html>