如何应用全局字体到整个HTML文档 [英] How to Apply global font to whole HTML document

查看:380
本文介绍了如何应用全局字体到整个HTML文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面,其中包含一些文本和格式。我想让它有相同的字体族和相同的文本大小忽略所有内部格式的文本。



我想为HTML设置一个全局字体格式



如何实现?

解决方案

能够在CSS中使用星号和!important 元素。

  html * 
{
font-size:1em!important;
color:#000!important;
font-family:Arial!important;
}

星号匹配一切(你可能没有<$ c $ c>

可以覆盖您在此风格中设置的(除非它也很重要)。 (这是为了帮助你的要求,它应该忽略内部格式化的文本 - 我认为其他样式不能覆盖这些)



其余的大括号内的样式就像任何其他样式,你可以做任何你想在那里。我选择更改字体大小,颜色和家庭为例。


I have a HTML page which includes some text and formatting. I want to make it have the same font-family and the same text-size ignoring all inner formatting of text.

I want to set a global font format for the HTML page.

How can I achieve this?

解决方案

You should be able to utilize the asterisk and !important elements within CSS.

html *
{
   font-size: 1em !important;
   color: #000 !important;
   font-family: Arial !important;
}

The asterisk matches everything (you could probably get away without the html too).

The !important ensures that nothing can override what you've set in this style (unless it is also important). (this is to help with your requirement that it should "ignore inner formatting of text" - which I took to mean that other styles could not overwrite these)

The rest of the style within the braces is just like any other styling and you can do whatever you'd like to in there. I chose to change the font size, color and family as an example.

这篇关于如何应用全局字体到整个HTML文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆