Using this CSS:
body > h1.title {
display: block;
font-size: 2em;
font-weight: bold;
margin: 0.67em 0;
font-family: Arial, Sans-Serif;
color: orange;
text-align: center;
text-transform: uppercase;
}
<h1 class="title">Back To Basics Log</h1>
renders like
Then, if I add <b></b> or <strong></strong> tags in
<h1 class="title"><b>Back To Basics Log</b></h1>
it looks like
Super bold! I expected a bold tag on content that was already font-weight: bold; to be disregarded, but it's actually made it even bolder.
Is there a way to get the second version (the one I'm seeing with the <b> tags added) through CSS?
--- Edit ---
Actually, I just tried commenting out font-weight:bold; and changes nothing! Is this a problem with my font? Why isn't font-weight:bold; working?
--- Edit 2 ---
It seems like the font is already bold from earlier stylings. When I use "lighter" as a value, that as working, so it seems the font is already bold. So the only question left is "is it possible to get super bold using just css?
Valid keywords for font-weights are:
lighter
normal
bold
bolder
So you might want to test bolder. Or numeric font weights in the range 100, 200, 300, 400, 500, 600, 700, 800, 900
Different fonts are only available in certain weights so you may need to experiment. For more info see https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
You can use font-weight: 900 instead of font-weight: bold. Because 900 is maximum value for this property and bold is the same as 700.
For example:
.title {
font-size: 2em;
font-weight: 900;
margin: 0.67em 0;
page-break-after: avoid;
font-family: Arial, Sans-Serif;
color: orange;
text-align: center;
text-transform: uppercase;
}
<h1 class="title">Back To Basics Log</h1>
While the various links in the other posts may explain things, SO policy is to always have the answers on the same page as the questions, to avoid having to click all those links.
Here we go then.
The answer is in the browser's built in style sheets. h1 has font-weight: bold by default, and b and strong have font-weight: bolder.¹
Now there are many different font weights. We don't have just normal and bold, we have 9 different ones, numbered 100 to 900.² The normal weight is 400, and the definition of bold is 700. The definition of bolder is "more bold than the font weight of the parent".
So if you have a h1 with a b inside, the h1 will be bold (i.e. weight 700), and the b inside will be bolder (i.e. more bold than 700).
That's basically all there is to it.
Knowing this, there are multiple solutions:
Use a font that has only two weights.
This is not the best way though. What if the next system update to the user's computer includes a version of this font with more weights?
Write b {font-weight: bold} in your stylesheet, or to be more thorough, h1 > * {font-weight: inherit}, so that the contents of the h1 will always be the same weight, no matter what.
Simply remove the <b> tags from the content of the h1. In this particular case, I don't see any reason to use them.
Or, leave everything as is and accept that you can put text inside a h1 that is even bolder. That might have its uses: <h1>Back to <strong>Basics!</strong></h1>
¹ This is not the case in all browsers though. That's why we need reset style sheets.
² Not all fonts have all font weights. Many have only two.
While looking for the answer to this question, I found that there is a different behavior among different browsers.
(I tested Chrome (Version 72.0.3616.0) and Internet Explorer 11)
<strong><span style="font-weight: bold;">Bold in Chrome, Super Bold in IE</span></strong>
<strong> with CSS font-weight: bold renders as bold in Chrome font-weight: 700; while IE sums things up ending with super-bold font-weight: 900;
Related
This font Glamora is displayed with more thick than it should be and other weird things
the font look like this,
but is displayed like this
this is the formatting for that text
.brand h1{
color: #FEF2DB;
font-family: Glamora;
font-size: 230px;
line-height: 68.1%;
text-align: center;
letter-spacing: 0.095em;
}
There’s probably only one weight of this font, ie. a single style with no bold version or other variants.
By default, h1 and all other headings are set to be bold, so you are probably getting some faux bolding, created by the browser.
Try adding:
.brand h1 {
font-family: Glamora;
/* Etc. */
font-weight: normal;
}
I was able to reproduce your issue, and adding font-weight: normal; fixed it:
This might also have something to do with how the font outlines or how the font file was built, or the fact that it hasn’t been produced as a web font.
The license doesn’t appear to allow converting it into a web font, but it might be worth getting in touch with the designer and seeing if they would produce WOFF and WOFF2 files for you, or modify the license to allow converting the format. That said, that might not impact the issue, and this CSS change does fix it.
I have set my h2 font-weight as 700, when I load my page, my H2 tags load with the correct font-weight (700) but half a second later bounce to a much lighter font-weight which is incorrect.
How can I stop the font-weight from changing?
It might be due to a confliction between my theme’s CSS and Bootstrap perhaps?
You can see an example at: https://www.moneynest.co.uk/how-to-budget/
See the text- ‘How to budget – Table of contents’.
Sam
For a fast solution set your font styling important that denies any change.
font-weight: 700 !important;
It looks like the following CSS file:
https://www.moneynest.co.uk/wp-content/themes/genesis-sample/A.style.css,qver=2.2.4.pagespeed.cf.dNG5vHCgAf.css
is adding the following rule:
h1.title{
font-weight: 300;
}
Either add !important to your CSS as Rudi suggested, or be more specific with your css override like so:
.site-inner h1.title{
font-weight: 700;
}
Hallelujah! I managed to fix it.
I ended up changing the font-family just on the <h2> tag from: Open Sans to Open Sans:700 I then threw an !important tag on it to avoid an overide and applied font-weight: bold;.
h2 {
font-family: "Open Sans:700",sans-serif !important;
font-weight: bold;
}
Note to self - keep things simple and avoid too many stylesheets.
body {
background-color: silver;
color: white;
padding: 20px;
font-family: Arial, Verdana, sans-serif;
}
What does it mean when there are multiple csv font families, like above?
It means that the font will fall back to the next font listed if the client's browser doesn't have the prior font available.
By listing out multiple fonts, you can ensure the client gets to see the font you want to display even if the first font you have listed is not available in their browser.
In your example:
body {
background-color: silver;
color: white;
padding: 20px;
font-family: Arial, Verdana, sans-serif;
}
Arial will fallback to Verdana which will fall back to sans-serif
Best practice:
Start with the font you want, and always end with a generic family, to let the browser pick a similar font in the generic family, if no other fonts are available.
As an interesting tidbit font-families can be significant on a character by character basis:
The font-family property specifies a list of fonts, from highest priority to lowest. Font selection does not simply stop at the first font named in the list that is on the user's system. Rather, font selection is done one character at a time, so that if an available font does not have a glyph that can display a character needed, the later available fonts are tried. However, this doesn't work in Internet Explorer 6 or earlier.
They're fallback options. The "sans-serif" is a generic family meaning the browser will select a default font that is also sans-serif.
My text that is supposed to be Arial Black is not working on Firefox. It's just displayed as a regular text. So I used Arial font with the Strong tag. I can't make a difference between the way they look. Is there anything I should worry about?
Thank you
EDIT
In this particular case I can't use CSS to do it so that's how i did it:
<font face="Arial Black, Arial, sans-serif"> <strong>Want an undergraduate course with more opportunity for hands-on practice? </strong></font>
Thanks for all the answers and explanations, I believe the strong tag is not wrong here as this is the most important part in the whole message. The visual difference wasn't noticed by anybody, that's confirmation enough for me.
I posted in jsfiddle and it surprised me the strong tag didn't add the bold effect i was expecting! The b did. You can clearly see the difference there! Thanks for that suggestion!
With regard to the question title (as the question text seems to ask differently):
The <strong> tag carries a semantic meaning. Citing MDN on this
The HTML Strong Element () gives text strong importance, and is typically displayed in bold.
So in the first place you should use this tag so mark up content, that you want to emphasize and not to get text marked bold.
Most browsers, however, will implement that emphasizing as just bold printed text.
If you just want to have bold text, use the respective CSS for it!
font-weight: bold;
<strong> holds a certain semantic meaning (along the lines of "more important"), and as such should be avoided purely to style something. If you want to "bold" the text, just add font-weight: 700.
Or you know, fix the reason Arial Black isn't working :P It may be that you didn't add speech marks around Arial Black.
font-family: Arial;
is completely acceptable, but
font-family: Arial Black;
is not. Make sure you have
font-family: "Arial Black";
Yes, there is a considerable difference in using Arial Black vs. Arial with the strong element. I will answer in CSS terms, substituting the CSS setting font-weight: bolder for HTML strong markup. (It's really irrelevant here whether you call for bold face directly in CSS or indirectly with HTML markup that implies a certain default setting.)
It is not clear what you mean by “Arial Black is not working on Firefox”.
The most logical CSS code for the purpose would be:
font-family: Arial; font-weight: 900;
This asks for the boldest available font in the Arial font family; that’s Arial Black when available, or else Arial Bold. Firefox does not seem to support this quite consistently, but many browsers have even more serious problems with font heights. (E.g., Chrome shows weight 600 as bolder than 700.)
In practice it is safer to use the old kludgy way, which refers to a specific font (typeface) as if it were a font family:
font-family: Arial Black;
For example, on IE 8, this is the only way to get Arial Black, whereas IE 9 supports the logical way, too (in “Standards Mode”).
If you use set the font to Arial and font weight to bolder, you get Arial Bold. If you set font-family: Arial Black and font-weight: bolder, you get Arial Black, because there is no bolder font. And Arial Bold and Arial Black are very different.
It’s impossible to say what went wrong in your first attempts, as you did not post the actual code used.
I think you would receive the same effect, however I would recommend using CSS styling instead of using the strong tag.
.arial-black{
font-family: Arial;
font-weight: bold;
}
There is no visual difference between the <strong>, <b> and font-weight:700|bold;.
However <strong> is used by screen readers (for the blind and partially sighted) to put emphasis on the text... therefore using a "bold" font will not result in the same thing for screen readers.
If you don't want to "emphasis" the text for screen readers, then I would recommend you use the <b> tag instead.
<strong> tag does not support all browsers, as Arial and Arial black is concerned both are different in size or weight you can say.
So answer to your question is yes.
Using the font Arial Black in a web page only works for the users that actually have that font installed. (Of course, using Arial also only works on systems that have that font).
Arial Black is not just a bold version of Arial. Although similar, Arial Black has a different look than the bold version of Arial:
Arial, bold
Arial Black
You should use a fallback font for all fonts that you use, so that the browser knows what to use if that specific font isn't available, however it's tricky to use a font that is bold by default, as you can't specify Arial bold as fallback for Arial Black. You would have to make do with using Arial as fallback:
font-family: 'Arial Black', Arial, Helvetica, sans-serif;
You could use a #font-face rule to force Arial Black whenever the bold font-weight of Arial is used:
#font-face {
font-family: Arial;
/* You can add other common names using comma-separated local definitions here */
src: local('Arial Black');
font-weight: bold;
}
#font-face {
font-family: Arial;
src: local('Arial');
font-weight: normal;
}
Now, whenever Arial is set as the font for an element and the calculated font weight is bold (which is what user agents set for the string tag in their html.css definitions), Arial Black is used instead.
strong tag basically creates your text in bold. For your case it makes no difference. But it will create a difference if your font is different and you are using "strong"
I'm having trouble with some CSS.
Currently I'm using #fontface which works fine and dandy.
However for the times that it doesn't I have implemented other fonts to be read however I'd like to style them all a bit differently.
For an example, if Rockwell is displayed I'd like the font-weight to be set to bold. But not if it is Times New Roman.
Furthermore, I'd only like the "letter-spacing: -4px;" to apply if Times New Roman is being displayed.
Is this even possible? And if so, please assist with some code.
h1{ font: 88px 'Chunkfive', Rockwell, Times New Roman, Georgia; letter-spacing: -4px; }
h1 span{ font: 88px Times New Roman, Georgia, serif; letter-spacing: -4px; }
You have expressed yourself clearly, don't worry.
I do not think there is a direct solution, however in some cases you can use this workaround.
Embed font.
Detect if you succeed (http://www.lalit.org/lab/javascript-css-font-detect/)
If yes/no add to <html> class="fontName" attribute.
In CSS add special declarations, like .fontName body { font-weight:bold; } - be prepared it means a lot of work. Especially with bolding - keep in mind how does <strong> will look like.
Good luck ;)
As every workaround it has some issues - like JS availability and so on. Maybe it will work for you.
What you are trying to do is definitely possible. In order for your script to work as you have it written. You need to follow the steps below:
Upload the font to your CSS directory (if thats where you want to host the font). (You can't just call the ChunkFive font without uploading the font to the directory your CSS is in based on your code)
Specify the #font-face above all your other CSS styles where you plan on using the font.
#font-face {
font-family: "ChunkFive";
src: url('chunkfive.ttf'); // Or whatever the font name is
}
Once you have accomplished steps 1 and 2 you can then call your font like you specified above :
h1{ font: 88px 'Chunkfive', Rockwell, Times New Roman, Georgia}
For a more definitive guide into font-face and CSS3 fonts I suggest reading this very thorough and informative blog post:
http://webdesignerwall.com/general/font-face-solutions-suggestions
Cheers and goodluck
Use two classes, one for each font
.font1 { font-family: 'Chunkfive'; font-weight: bold; }
.font2 { font-family: 'Times New Roman'; letter-spacing: -4px; font-weight: normal; }
Then in your HTML, use them like
<h1 class="font1">...</h1>
<div class="font2">...</div>