PDA

View Full Version : Text Formatting



doubleH
Oct 21st, 2008, 01:30 AM
Hello,

This sounds really simple, but for some reason I can't get it to work. I have a block of text inside a DIV. That works fine. Now within this block of text I want to change the colour of a few words. I can do this with another DIV but it adds a return (like a BR was typed) so the text appears on the next line. I don't want that, just want to change the colour on some text. Can someone help?

Thanks!

JygzIsHere
Oct 21st, 2008, 01:37 AM
apply css inline display in the div



<div>Lorem
<div style='display:inline;color:dodgerblue'>ipsum</div> dolor....
</div>

doubleH
Oct 21st, 2008, 01:47 AM
awesome thanks!

Lochlan
Oct 21st, 2008, 04:44 AM
You should really use a span, as it's an inline element already and a div is block.



<div>
Lorem<span style='color:dodgerblue'>ipsum</span> dolor....
</div>

Or if the different colour was always going to be the same you could just do:




<div>
Lorem<span>ipsum</span> dolor....
</div>

And then make a CSS rule like:



div span {
color:dodgerblue;
}


Or if reusing a series of colours then give the span a class and set the different classes. :)