How to display gradient text effects without an image in HTML?

Recommended Answers

All 2 Replies

This question should probably be moved by a moderator to the web development section of the forums, but as far as your query goes: using images is a good way of achieving cross-browser compatibility. But if you do not want to use images, you can use CSS to achieve a gradient effect - look here :

http://slayeroffice.com/code/gradient/

Welcome to DANIWEB Minald!:)
Please post in the right forum.
However if you want to do this in a forms application you could do something like:

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace GradientText
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.Width = 900;
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics G = e.Graphics;
            string strText = "Gradient";
            Font font = new Font("Arial", 144, FontStyle.Italic);
            SizeF aSize = G.MeasureString(strText, font);
            PointF aPoint = new PointF(20f, 20f);
            RectangleF aRect = new RectangleF(aPoint, aSize);

            LinearGradientBrush aBrush = new LinearGradientBrush(aRect, Color.White, Color.Blue,
                LinearGradientMode.ForwardDiagonal);
            G.Clear(Color.Gray);
            G.DrawString(strText, font, aBrush, aPoint);
        }
    }
}
commented: Nice! +5
Be a part of the DaniWeb community

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