We help IT Professionals succeed at work.

Using inline styles to change text characteristics mid paragraph

Azra Lyndsey
Azra Lyndsey asked
on
I have a paragraph wrapped with

The trouble is need to change two words in one sentence to red italic.

My code looks something like this:

<p class="txt">
     blah blah blah <style="color: red; font-style: italic;">blah blah</style> blah blah blah
</p>

Open in new window


This, of course doesn't work because I don't have a selector like p in front of "style".  The thing is, I'm not sure what selector to use there.  

What selector can I use?
Comment
Watch Question

span.
Some normal and <span style="color:red">Some Red</span> text.
Commented:
If you wrap it in a span, you can set the style on that

<p class="txt">
     blah blah blah <SPAN style="color: red; font-style: italic;">blah blah</SPAN> blah blah blah
</p>
Commented:
Wrap the two words with a <span> tag.

<p class="txt">
     blah blah blah <span style="color: red; font-style: italic;">blah blah</span> blah blah blah
</p>

Open in new window

Author

Commented:
!!!  I knew that I was missing something silly like that.  I just couldn't remember what it was  Ha!

Thanks.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.