Html 我可以给标题标签一个颜色和不同的字体吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13579477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:06:32  来源:igfitidea点击:

Can I give a title tag a color and different font?

csshtmltagstitle

提问by absolute neXus

I was wondering if there is a way to give a page title a different color and font in the page tab. Something like:

我想知道是否有办法在页面选项卡中为页面标题提供不同的颜色和字体。就像是:

title{ color: red; font: 12px tahoma;} 

Just thought it would be fun to add into sites. I tried the above and it didn't work in my CSS file. Also tried giving it a class="title"giving it a CSS style of .title{ color: red; font: 12px tahoma;}but that didn't work either.

只是认为添加到网站会很有趣。我尝试了上述方法,但在我的 CSS 文件中不起作用。还尝试给它一个class="title"CSS 样式,.title{ color: red; font: 12px tahoma;}但这也不起作用。

采纳答案by Mr. Alien

Answer is NOyou cannot do that in any way....you cannot apply any styles to page title, btw you can just blink the titles

答案是NO你不能以任何方式做到这一点......你不能对页面标题应用任何样式,顺便说一句,你可以只闪烁标题

Blinking Titles

闪烁的标题

More Info On CSS Which You Are Using:

有关您正在使用的 CSS 的更多信息:

If you are declaring something like this

如果你要声明这样的东西

title{ color: red; font: 12px tahoma;} 

You don't need to define any class as you are targeting specific title tag which is only 1 in your whole document

您不需要定义任何类,因为您的目标是整个文档中只有 1 个的特定标题标签

And if you are using .titlethan your CSS should be

如果你使用.title的 CSS 应该是

.title{ color: red; font: 12px tahoma;} 

回答by Ryan McDonough

If you are talking about the <title></title>section then no you can't style it.

如果你在谈论这个<title></title>部分,那么不,你不能设计它。

If you are talking about the title of a page as in a header tag such as h1 or h2 then yes you can style those using normal CSS styling techniques such as

如果您正在谈论页面标题,如 h1 或 h2 等标题标签,那么是的,您可以使用普通的 CSS 样式技术来设置样式,例如

.title { color: #1A1A1A }

<h1 class="title">My Awesome Title</h1>

回答by Devin G Rhode

The previous answers are correct, but, you can sort of get different fonts if they are defined in unicode. I don't know how to explore this, but, for example, there's the regularly written word javascriptand then there's this title I coped from reddit.com/r/javascript source code: - notice how they are slightly different.

前面的答案是正确的,但是,如果它们是在 unicode 中定义的,您可以获得不同的字体。我不知道如何探索这个,但是,例如,有经常写的词javascript,然后有我从 reddit.com/r/javascript 源代码中处理的这个标题:- 注意它们是如何略有不同的。

Regular without code delimiters: javascript

没有代码分隔符的常规:javascript

Reddits title without code delimiters:

没有代码分隔符的 Reddits 标题:

You can copy past these characters anywhere and they are going to look different, because they are technically _different characters. There's a and then there's - I grabbed this from the javascript word I previously pasted.

您可以在任何地方复制这些字符,它们看起来会有所不同,因为它们在技术上是不同的字符。有一个然后有 - 我从我之前粘贴的 javascript 词中抓取了这个。

I don't know where these characters came from. I don't know how to type them. I don't know where one could copy paste them from.

我不知道这些字符是从哪里来的。我不知道如何输入它们。我不知道从哪里可以复制粘贴它们。

But it proves an interesting point - any emoji can be used in these titles, you can copy paste from https://www.emojicopy.com/

但它证明了一个有趣的点 - 这些标题中可以使用任何表情符号,您可以从https://www.emojicopy.com/复制粘贴

回答by Arthur Annibal

You can style the <title>tag, just add "display:block" or "display:inline" to it.

您可以设置<title>标签的样式,只需添加“display:block”或“display:inline”即可。

title {
    display:block;
    color:red;
    font:12px tahoma, serif;
}

that way it should appear inside your page with the same content of the tab on the browser, for instance.

例如,这样它应该与浏览器上选项卡的相同内容出现在您的页面中。

As for the Page Title, i have seen that it is possible to style it, someway. probably with shadow dom.

至于页面标题,我已经看到可以以某种方式对其进行样式设置。可能与影子 dom。