

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Using the combination of Percentage and Em in CSS
We can use a combination of percentage and em to specify the font-size of elements for better compatibility of font. This allows us to have uniform text across different browsers.
Syntax
The syntax of CSS font-size property is as follows −
Selector { font-size: /*value*/ }
Example
The following examples illustrate how CSS font-size property can be set with keywords −
<!DOCTYPE html> <html> <head> <style> body { font-size: 80%; } p { font-size: 2em; } span { font-size: 4em; font-style: italic; } </style> </head> <body> <p>Reading <span>source code</span> written by others gives you opportunity to criticize the mistakes done in writing that code</p> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html> <head> <style> div { font-size: 120%; } p { font-size: 2em; } </style> </head> <body> <h3>Demo Heading</h3> This is example text. <div> Examples are easier to understand with practical implementation <p>This is another text just to display different ways to set font size in CSS.</p> </div> </body> </html>
Output
This gives the following output −
- Related Questions & Answers
- Set Font Size with em using CSS
- Setting Font Size with Em Using CSS
- Setting Font Size with Em in CSS
- Difference between PX, EM and Percent
- Using combination of “AND” and “OR” in SELECT in ABAP
- Permutation and Combination in Java
- Permutation and Combination in Python?
- Combination sum problem using JavaScript
- Count number of strings (made of R, G and B) using given combination in C++
- Why combination of twitter and facebook is bad
- Compare Strings in JavaScript and return percentage of likeliness
- What is the percentage of the completion method?
- Change the width and height of element using CSS
- Check if the string is a combination of strings in an array using JavaScript
- Give examples for the percentage of completion method
Advertisements