Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I style a specific word with CSS in an HTML element?

Tags:

css

fonts

tags

How do I style a specific word within <p> tags? EX: STUDIO X is the best studio ever.

^^How do I, using css, make "STUDIO X" a different font than "is the best studio ever?"

like image 637
AMC Avatar asked Dec 27 '22 22:12

AMC


2 Answers

You should do this:

p {
  font-size: 12px;
}

span {
  font-size: 16px;
  font-weight: bold;
}
<p>
  <span>STUDIO X</span> is the best studio ever
</p>

I recommend you to define a specific class for <p> and <span> tags, it will prevent unexpected overwrites.

like image 62
Marcio Mazzucato Avatar answered Jan 13 '23 14:01

Marcio Mazzucato


You can wrap it with a span tag

<p><span class="best_studio">STUDIO X</span> is the best studio ever.</p>

and use CSS to define the style

.best_studio {
  font-family: Arial,
  font-size: 22px
}
like image 29
Elvis D'Souza Avatar answered Jan 13 '23 14:01

Elvis D'Souza