Forum Moderators: not2easy

Message Too Old, No Replies

CSS Novice Flummoxed

Problem with text colour

         

Syzygy

12:37 pm on Jun 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'll hold my hands up now and state I'm still getting to grips with CSS and up until now thought I at least had a grasp of most of the rudiments. However...

In a block of text I want to highlight a few words in a different colour.

But, on applying it the chosen words end up on a new line

like this
rather than remain in the flow of the text, which is where I need them to be.

Code side it's applied <div class="yellow">like this</div>.

.yellow {
font-weight: bold;
color: #FF9900;
}

Any suggestions as to why this might be happening or where I should be looking for the problem? Oh, and be gentle..;-)

Syzygy

Receptional Andy

12:40 pm on Jun 2, 2008 (gmt 0)



A div is a block-level element, which means it will break the text up as you suggest. For changing words within an existing block level element, use an inline element like <span> instead. There may be a more appropriately tag to use, depending on why you are highlighting which you can still style appropriately (e.g. <em> or <strong>).

Syzygy

8:28 pm on Jun 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ha, thanks. Span-tastic!

It's amazing how you think you're starting to make progress with something, then along comes a little spanner in your proverbial works and you realise just how little you really know!

Syzygy