Set font size u...LOGIN

Set font size using % and em

Example analysis:

is the body element (parent element) sets the default font-size value in percentage, and then sets the font size of the <h1> and <p> elements (child elements) in em. This can effectively solve the problem of em in IE browser and can adjust the text size in all browsers.


Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style> body {font-size:100%;} h1 {font-size:2.5em;} h2 {font-size:1.875em;} p {font-size:0.875em;} </style> </head> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> <p>This is a paragraph.</p> <p>在所有浏览器中,可以显示相同的文本大小,并允许所有浏览器缩放文本的大小。</p> </body> </html>
submitReset Code
ChapterCourseware