What I want to accomplish is to have one division with the first part of the text red and the second part green. How would I do that?

Recommended Answers

You mean that you wnt to have the first part of a text green and the second red

//add your css
<style>

#green p{color:green;}
#red   p{color :red;}

</style>
<div id="main">

    <div id="green">
    <p>Hello</p>
    </div>

    <div id="red">
    <p>World</p>
    </div>

</div>
Jump to Post

All 2 Replies

You mean that you wnt to have the first part of a text green and the second red

//add your css
<style>

#green p{color:green;}
#red   p{color :red;}

</style>
<div id="main">

    <div id="green">
    <p>Hello</p>
    </div>

    <div id="red">
    <p>World</p>
    </div>

</div>
commented: I imagined something very complicated. Thank you! +0

If one div is required, you can place a span element around the text that you want to format differently, then apply a style on that span element. Or you can do this with jQuery. Please clarify exactly what you are trying to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.