0

How do I change the text color for a specific piece of text when I have a text color set inside the body tag. It doesn't seem to work. Am I doing something wrong or is there a better way of going around this?

<body style="background-color: black; color: white">
<p>Hello!</p>

Hope this wasn't confusing as I am not the best at explaining things!

Beedgehog
  • 11
  • 1
  • The "better" way of doing this is to use a stylesheet instead of inline styles. Even `` would be better. But I see no code where you're trying to set a text color for a specific piece of text... – Heretic Monkey Apr 23 '21 at 17:41
  • Does this answer your question? [HTML: Changing colors of specific words in a string of text](https://stackoverflow.com/questions/4622808/html-changing-colors-of-specific-words-in-a-string-of-text) – Heretic Monkey Apr 23 '21 at 17:42

1 Answers1

1

If I understood your question right, you want to change the color of the "Hello!", but not the rest of the body? If so, you can just use a seperate style for the p tag:

<p style="color: red">Hello!</p>

Sorry, if I didn't understand the question properly.

hubschrauber
  • 55
  • 10