如何在html中更改标题的字体系列?

问题描述 投票:0回答:3

我学会了通过做<p style="font-family:;></p>改变体内文本的字体系列,但是我如何为标题做呢?另外,有没有办法修复整个文档的字体系列?

html font-family
3个回答
0
投票

你想在style.css中使用(html {})因此,它将适用于你的(HTML)中的任何元素。除非你另有明确说明。

关于这个问题,在这个例子中,我给你如果你要删除child1或child2字体系列,它将默认为body部分中的任何内容,如果要从body中删除font-family,它将默认为HTML。

[

/*Change the font style on the Entire Document */
html{
  font-family: "Montserrat", sans-serif;  
  font-size: 1rem;
  color: Gray;
}

/*Change on the Body*/
body{
   font-family: "Montserrat", sans-serif;  
  font-size: 2rem;
  color: white;
  background-color: #333;
  text-align:center;
}
/*Change on a specific elements*/
#container .child1{
  font-family:  cursive;
  font-size: 2rem;
  color: white;   
  text-align:center;
  background-color: blue;
}

#container .child2{
  font-family: cursive;
  
  font-size: 2rem;
  color: white;
  background-color: green;
  text-align:center;
}

footer{
 font-family:  'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
<header>
  <p>I am the Header</p>
</header>

<div id="container">
    <div class="child1">
    <p>I am a Body Child</p>
    </div>

 <div class="child2">
      <p>I am another body Child</p>
    </div>
</div>

<footer> I am the Footer</footer>

] 1


0
投票

如果您真的想要设置整个文档,您可以使用下面的注释,除非您指定!important,否则更具体的选择器会覆盖它!(尽管我强烈建议不要在选择器上使用!important):

body {
    font: normal 10px Verdana, Arial, sans-serif;
}

-3
投票

您可以在HTML文件的head元素中编写样式元素,以在整个文档中全局应用样式:

<style>
title {
font-family:; /* usually the name of your font goes here */
}
</style>
© www.soinside.com 2019 - 2024. All rights reserved.