Html 任何想法为什么 <strong> 标签不起作用但 CSS 起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6813750/
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
Any ideas why <strong> tag doesn't work but CSS does?
提问by Tom Gullen
<span class="bold">Some Title</span>
.bold
{
font-weight:bold;
}
This renders boldly, however this:
这大胆地呈现,但是:
<strong>Some Title</strong>
Does not. It just renders as regular text. I'm using the HTML5 doctype and the Google font:
才不是。它只是呈现为常规文本。我正在使用 HTML5 文档类型和 Google 字体:
<link href='http://fonts.googleapis.com/css?family=Droid+Sans&v2' rel='stylesheet' type='text/css'>
Anyone experienced this as well?
有谁也遇到过这种情况吗?
Edit: BoltClock suggested it might be CSS reset, here's the chunk for <strong>
编辑:BoltClock 建议它可能是 CSS 重置,这里是块 <strong>
/** CSS Reset **/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
回答by BoltClock
If there is nothing else for strong
, then there's your problem (or rather, the CSS reset's problem).
如果没有别的strong
,那么就是你的问题(或者更确切地说,是 CSS 重置的问题)。
The font: inherit
style, together with all those selectors, is asking everything to inherit every font style from its parent. The default weight is, obviously, normal
, so strong
text is no longer bold until you redeclare it:
的font: inherit
风格,再加上所有的选择,是要求一切继承其父每个字体样式。显然,默认权重是 ,normal
因此strong
在您重新声明之前,文本不再是粗体:
strong { font-weight: bold; }
(Some other obvious elements to reset styles for are b
, em
, i
, code elements, quote elements, tables, headings, lists, etc.)
(用于重置样式的其他一些明显元素是b
、em
、i
、 代码元素、 引用元素、 表格、 标题、 列表等)
回答by avall
add:
添加:
strong{
font-weight:bold;
}
to your CSS. Maybe somewhere you reset this tag.
到您的 CSS。也许你在某个地方重置了这个标签。
回答by Pavel Hasala
Those resets are reseting not just padding and margins, as BoltClock explained, font:inherit
can break your browsers deafault behaviour with displaying proper fonts style.
正如 BoltClock 解释的那样,这些重置不仅仅是重置填充和边距,font:inherit
还可以通过显示正确的字体样式来破坏浏览器的默认行为。
回答by vikrant
In addition to BoltClock's answer, I also found out that we must use the complete tag names for closing the tags, otherwise the STRONG tag used afterwards doesn't work. For example,
除了 BoltClock 的回答,我还发现我们必须使用完整的标签名称来关闭标签,否则之后使用的 STRONG 标签不起作用。例如,
<H1> heading </H1>
<H1> heading </H1>
instead of,
<H1> heading </>
<H1> heading </>