This forum is now read-only. Please use our new forums! Go to forums
Hi, I didn’t want to only use the p style=”color:blue”- /p because that makes the whole paragraph blue & if I try to put it around just one word, the word is obviously shifted onto a new paragraph. I found - font color=red - online & used it before the word I wanted to be red and had to use - font color=black, to get the words back to black so that just the word “Sheffield” was red. Is it ok to use or is there now a better, more acceptable way ?
When I try to copy my code here, it alwasys shows rendered version, how do I copy code to show as code ?
Answer 519931cb32450b3c3c002c2d
1
vote
Hi Chrissy52, as far as posting your code, sometimes it takes a few tries.To colored just one word you can use <span style="your style"> WORD</span>
.This way you don’t have to style the whole paragraph.Example: <p> The quick brown <span style="color: brown">fox</span> jumps over...</p>
.This colors the “fox” word brown.
SPAN is a more localized way to style. Also if you are using an stylesheet, you can give your span an id# instead of “color” and apply the color on the external stylesheet instead. But the trick is to wrap your word in <span></span>
.
2 comments
over 10 years
Thanks so much, I have copied your post so I can remember. I haven’t got onto learning about stylesheets yet, I assume that is in CSS ? but think I understand what you are saying about assigning an id# to a certain style eg color:blue in the stylesheet so that throughout the html you only have to write the id# in. Maybe that’s not quite right but just telling me that now is helping me build up a schema of how this language works. Thank you.
over 10 years
That’s it! Just keep in mind the following concept: you can choose an id or you can choose a class. Classes can be reused on the same page as many times as you wish, however, ids can only be used once per page such as to style 1 footer or 1 head. You will get an error if yo use an id twice on the same page. This is a lot of fun!
Popular free courses
Free Course
Learn SQL
Beginner friendly,
4 Lessons
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
Language Fluency
Free Course
Learn JavaScript
Beginner friendly,
11 Lessons
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
Language Fluency
Free Course
Learn HTML
Beginner friendly,
6 Lessons
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
Language Fluency