What could cause a bold tag <b> to be ignored?

Deadly 提交于 2019-12-12 12:52:20

问题


I have an issue with some HTML displayed in Drupal, but I am not 100% sure this is a Drupal issue. I am using the bold tag to emphasize a word, but it is not displayed as bold. It thought it might be the Google font I used, so I disabled it, but I still get the issue.

I checked the page source:

<div id="begin_block">
  <div id="fw_begin"><h2>Find words <b>beginning</b> with:</h2></div>
    <div id="inp_begin"><input type="text" /></div>
    <div id="aft_begin">(max. 5 characters)</div>
    <div id="but_begin"><button type="button">Go</button></div>
</div>

But I still get:

What could be causing this issue?

UPDATE

There is indeed a reset.css in the theme I am using. Bold is defined as:

b{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}

回答1:


A CSS (reset) sheet has probably defined b{font-weight:normal;}. To "fix" the style, add b{font-weight:bold;}.

Also, he <strong> tag is semantically more correct, so use that instead of <b>.




回答2:


What you need to do is to use firebug or google's developer console in order to debug it. If you do not have any prior experience with at least one don't worry - it will pay of to spend some time and to learn it.

As the real solution, you could wrap your text in <span> instead of <b>, add it some meaningful class like "stress" (but you should avoid class names like "bold" because you might end up with changing your mind and instead of font-weight you will use underline, and in such case you will either change a class name or have bold class for underline style) and add to it something like

.stress{
 font-weight: bold !important;
}

Most likely you overwrite font-weight somewhere and important will ensure that it won't get overwritten anymore.

BTW: of course you do not have to use <span> with a class name, you can also use other selectors like <strong> etc.



来源:https://stackoverflow.com/questions/9751679/what-could-cause-a-bold-tag-b-to-be-ignored

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!