Any ideas why <strong> tag doesn't work but CSS does?
Asked Answered
A

6

15
<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:

<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>

/** 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;
}
Annulment answered 25/7, 2011 at 8:59 Comment(4)
Do you happen to have a CSS reset that forgot to "reset" styles for strong?Lookthrough
If you are trying this in jsfiddle uncheck Normalized CSSVickery
@Bolt yes I am! But I'm not sure how this would interfere?Annulment
I posted an answer to explain.Lookthrough
L
53

If there is nothing else for strong, then there's your problem (or rather, the CSS reset's problem).

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:

strong { font-weight: bold; }

(Some other obvious elements to reset styles for are b, em, i, code elements, quote elements, tables, headings, lists, etc.)

Lookthrough answered 25/7, 2011 at 9:4 Comment(1)
tl;dr inherit means inherit from parent element, not inherit browser defaultsLookthrough
O
10

add:

strong{
 font-weight:bold;
}

to your CSS. Maybe somewhere you reset this tag.

Outwit answered 25/7, 2011 at 9:3 Comment(0)
S
1

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.

Stellate answered 17/1, 2016 at 12:53 Comment(0)
O
0

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,

<H1> heading </H1>

instead of,

<H1> heading </>

Oleomargarine answered 30/7, 2014 at 22:45 Comment(4)
Is the situation where </> is actually valid? Genuinely curiousTrueman
looks like they are not valid. #3558619Oleomargarine
I think that question is discussing self closing such as <img /> - I was curious about the use of </>Trueman
</> or <img/> is not valid, according to the specs, but the browser still renders it. it should be like this: <img> </img>. it is under the section "end tags" have a look: w3.org/TR/html5/syntax.html#void-elementsOleomargarine
G
0

For me the issue was Angular Material .mat-option class, for some reason using <b> or <strong> didn't work with their font. Changing their font to another one solved the issue for me.

Galluses answered 20/12, 2020 at 10:26 Comment(0)
T
-1

You can see the strong tag is strikethrough (invalid) in elements tab by em or s or any tag when checked CSS.

You should add the code below in main.css:

b,
strong * {
  font-weight: bold !important;
}
Thais answered 25/5 at 3:41 Comment(1)
Really shouldn't be using !important unless you have no other option to take precedence (ie: if you don't have access to the HTML and someone has inline style attributes).Euphemia

© 2022 - 2024 — McMap. All rights reserved.