Reputation: 3898
I have a paragraph with some text in it. How do I change the color of just one word w/in that paragraph? My attempt at it ends up changing the color of 'is' but also puts 'is' on it's own line.
<div class="myHeader">
<h1>This is my heading</h1>
<h2>This <div class="test">is</div> the paragraph</h2>
</div>
css file:
.myHeader {
text-align: center;
font: normal Helvetica, Arial, sans-serif;
color: #ffffff;
}
.test{
color: red;
}
Upvotes: 3
Views: 12429
Reputation: 78520
You have two options. You can either change the div to a span as esqew noted or you can change your style rule to this
.test{
display:inline;
color: red;
}
effectively treating the block level div as a span.
Upvotes: 1
Reputation: 4766
What i would do for <div class="test">is</div>
is make it <div id=test>is</div>
then change the css to
#test{
color:red;
}
hope this helps :)
Upvotes: -4
Reputation: 44699
Instead of having .test
be a div
, use something like span
.
It's getting it's own line because div
is a block element, while span
and the like are inline.
Upvotes: 9