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

How to set div font size in css

王林
王林Original
2021-06-22 15:09:125509browse

The way to set the font size of a div in css is to add the font-size attribute to the div font and set the appropriate font size, such as [div {font-size:200%;}].

How to set div font size in css

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

To set the font size of a div, you can use the font-size attribute in css. By using the font-size attribute, we can easily set the font size. But some friends may not know the font-size attribute. Let's briefly introduce this attribute.

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

What are the commonly used 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.

Code example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文网(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>

The running effect is as follows:

How to set div font size in css

Related recommendations: css video tutorial

The above is the detailed content of How to set div 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
Previous article:How to hide css stylesNext article:How to hide css styles