Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change color css only first 6 character of text

Tags:

html

css

I have phrase as Client Testimonial and i want to change only the Client i have used only first-letter but is there any method in css to change color .. no javascript please.

like image 518
Rafee Avatar asked Aug 31 '12 15:08

Rafee


People also ask

How do I change the color of one letter in CSS?

From css you can only change an elements property so you need to insert the letter "A" in another element like this: ST<span>A</span>CK OVER FLOW just the 'A' letter is red! ST<span class="myRedA">A</span>CK OVER FLOW just the '<A' letter is red! Save this answer.

How do you make each letter a different color in CSS?

This is the easiest way of creating such kind of text. Put your text in a <span> tag and give it a class name "multicolortext". Then, you need the CSS background-image property to add a gradient background to your text with its "linear-gradient" value, where you put the names of your preferred colors.

How do I change a specific color in CSS?

Simply add the appropriate CSS selector and define the color property with the value you want. For example, say you want to change the color of all paragraphs on your site to navy. Then you'd add p {color: #000080; } to the head section of your HTML file.


1 Answers

How about using :before?

I would change the text from "Client Testimonial" to "Testimonial", and then with CSS apply the :before rule:

HTML:

<div class="word">Testimonial</div>​​​​​​​​

CSS:

.word {
 color: black;       
}
.word:before {
 color: red;
 content: "Client ";
}

Example: http://jsfiddle.net/LvZt7/

like image 91
jackJoe Avatar answered Oct 07 '22 02:10

jackJoe