Home  >  Article  >  Web Front-end  >  How to modify font size in css

How to modify font size in css

王林
王林Original
2021-05-21 15:28:1920781browse

The way to modify the font size in css is to add the font-size attribute to the font and set the attribute value to an appropriate value, such as [h2 {font-size:200%;}], which means The font size is set to 200% based on the parent element.

How to modify font size in css

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

It is very simple to modify the font size in CSS. We only need to use the font-size attribute to do it easily. Let’s take a look at this property first.

The font-size property is used to set the font size.

Common attribute values:

  • 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.

Let’s take a look at the specific code examples:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title></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>

Related video tutorial sharing: css video tutorial

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

Statement:
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