views:

146

answers:

2

Can I have such effect in HTML without using an image?

The text should be editable with this effect.

Make me editable

+2  A: 

You may want to check the CSS Gradient Text Demo by Web Designer Wall.

It still uses png images to achieve the gradient, but it satisfies "text should be editable with same effect", if by editable you meant that it can be highlighted, copied, crawled, etc.

UPDATE:

Further to the comments below, you may want to consider using the HTML 5 contenteditable attribute. You may be able to apply the gradient technique described above over the editable text.

You would use normally use the contenteditable attribute as follows:

<section id="editable" contenteditable="true"> 
   <h1>Gradient Text Here</h1> 
</section>

If you add the <span></span> into your <h1> as described in the tutorial above, I believe it should work.

This was not tested. Let us know how it goes if you try it out!:

CSS:

h1 {
   font: bold 330%/100% "Lucida Grande";
   position: relative;
   color: #464646;
}

h1 span {
   background: url(gradient.png) repeat-x;
   position: absolute;
   display: block;
   width: 100%;
   height: 31px;
}

HTML:

<section id="editable" contenteditable="true"> 
   <h1><span></span>Gradient Text Here</h1> 
</section>

The CSS Gradient Text Effect Tutorial will tell you how to create the gradient.png.

In addition, make sure to check the html5demos.com - contenteditable demo to see the HTML 5 contenteditable attribute in action.

Daniel Vassallo
I should allow me typing in it.
Ashish
and not 'just' selectable as this CSS demo allow
Veger
I'm sorry, I misunderstood the original question. Check my updated answer for a few tips.
Daniel Vassallo
Just a quick note - the contenteditable attribute isn't just in HTML5 - it's got remarkably wide support. I tested it out in this example (using Firebug) and it works fine.
David Heggie
A: 

WebKit has something you might like: http://webkit.org/blog/164/background-clip-text/

Ms2ger