How to change font size in css

王林
Release: 2023-01-03 09:27:37
Original
6231 people have browsed it

To change the font size in CSS, you can use the font-size attribute, such as [font-size:smaller;], which means to set the font to a smaller size than the parent element. If we need to set the font size to a fixed value, we can use [font-size:length;].

How to change font size in css

The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.

There is a property font-size in css specially used to set the font size. We can use this property to set the font size ourselves.

Attribute value:

  • smaller Set font-size to a smaller size than the parent element.​

  • larger Set font-size to a larger size than the parent element.

  • #length Set font-size to a fixed value.​

  • % ​ Set font-size to a percentage value based on the parent element.

  • #inherit Specifies that the font size should be inherited from the parent element.

(Learning video sharing: css video tutorial)

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php.cn</title>
<style>
h1 {font-size:250%;}
h2 {font-size:200%;}
p {font-size:100%;}
</style>
</head>

<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<p>This is a paragraph.</p>
</body>

</html>
Copy after login

Running result:

How to change font size in css

Related recommendations: CSS tutorial

The above is the detailed content of How to change font size in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template