Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change font color mid-sentence

Tags:

html

css

What is the correct way to change the color or font face for a single word or set of words within a sentence? I am using Twitter Bootstrap and want to inherit all the attributes of the <div>'s class, but only tweak them slightly.

like image 469
dugla Avatar asked Nov 27 '12 12:11

dugla


People also ask

How do you change the font color while typing?

Go to Format > Font > Font. + D to open the Font dialog box. Select the arrow next to Font color, and then choose a color.

How do you change the font mid paragraph in HTML?

How to Change Font Size in HTML. To change font size in HTML, use the CSS font-size property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.


1 Answers

Going off of Chords comment, you can create a <span> tag that surrounds the text you want to change. You can easily add multiple classes to a single span to achieve just the look you want as well.

Here's a fiddle to show how you can use multiple classes on a single span.

CSS

.bold { font-weight: bold; }
.red { color: #FF0000; }
.yellow-background { background-color: Yellow; }​

HTML

Here is <span class="bold">some text</span> that we are going to apply 
<span class="bold red">different styles</span> to. You can see how 
<span class="bold yellow-background">multiple classes</span> can be used to 
change the <span class="red bold yellow-background">look and feel</span> 
of the text.​
like image 156
Jason Towne Avatar answered Oct 26 '22 09:10

Jason Towne