To colour just one word | Codecademy (2024)

Skip to ContentMini Arrow Down Icon

This forum is now read-only. Please use our new forums! Go to forums

points

To colour just one word | Codecademy (1)

Submitted by

Chrissy52

over 10 years

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

Permalink

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>.

points

To colour just one word | Codecademy (2)

Submitted by

tony de araujo

over 10 years

2 comments

To colour just one word | Codecademy (3) Chrissy52

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.

To colour just one word | Codecademy (4) tony de araujo

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!

To colour just one word | Codecademy (2024)
Top Articles
Latest Posts
Article information

Author: Manual Maggio

Last Updated:

Views: 5335

Rating: 4.9 / 5 (49 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Manual Maggio

Birthday: 1998-01-20

Address: 359 Kelvin Stream, Lake Eldonview, MT 33517-1242

Phone: +577037762465

Job: Product Hospitality Supervisor

Hobby: Gardening, Web surfing, Video gaming, Amateur radio, Flag Football, Reading, Table tennis

Introduction: My name is Manual Maggio, I am a thankful, tender, adventurous, delightful, fantastic, proud, graceful person who loves writing and wants to share my knowledge and understanding with you.