Keep separate text on same line as div tag
I am using CSS to make a portion of my text font bold. But I don't want the whole line to be bold. Only part of the text. How can I achieve this? Here is my code:
Html
<div>
<div id="titleLabels">Revision:</div> 1.0 draft A
</div>
CSS
#titleLabels
{
font-weight: bold;
}
The result of this:
This is not what I want. I want the "1.0 draft A" bit embedded in the bit that says "Revision".
How can i do this?
Just add display:inline
to #titleLabels
:
#titleLabels {
font-weight: bold;
display:inline;
}
<div>
<div id="titleLabels">Revision:</div>1.0 draft A
</div>
Divs are block level elements by default and will span the entire width of their parent unless you change this.
More logical solution would be to not use divs in the text of the audit and instead use either <strong>
, <b>
or <span>
with a font style.
#titleLabels {
font-weight: bold;
}
<div>
<b>Revision:</b>1.0 draft A
</div>
<div>
<strong>Revision:</strong>1.0 draft A
</div>
<div>
<span id="titleLabels">Revision:</span>1.0 draft A
</div>
source to share
Use display:inline-block
#titleLabels
{
font-weight: bold;
display:inline-block;
}
<div>
<div id="titleLabels">Revision:</div> 1.0 draft A
</div>
source to share