Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could use SVG, its a little outside the box, but its cross browser compatible and gives you some more options.</p> <p><strong><a href="http://jsfiddle.net/apaul34208/XfHa3/5/" rel="nofollow noreferrer">Working Example</a></strong></p> <pre><code>&lt;svg height="50"&gt; &lt;linearGradient id="g1" x="0%" y="100%"&gt; &lt;stop stop-color="blue" offset="0%" /&gt; &lt;stop stop-color="green" offset="25%" /&gt; &lt;stop stop-color="yellow" offset="50%" /&gt; &lt;stop stop-color="orange" offset="75%" /&gt; &lt;stop stop-color="red" offset="100%" /&gt; &lt;/linearGradient&gt; &lt;text font-size="40" fill="url(#g1)"&gt; &lt;tspan x="10" y="40"&gt;Hello World!&lt;/tspan&gt; &lt;/text&gt; &lt;/svg&gt; </code></pre> <p>Tested and working in Chrome, Firefox, and IE9</p> <p>If you've really got your heart set on a cutout effect, it can also be done with SVG.</p> <p><strong><a href="http://jsfiddle.net/apaul34208/XfHa3/15/" rel="nofollow noreferrer">Working Example 2</a></strong></p> <pre><code>&lt;div class="wrap"&gt; &lt;div class="black"&gt; &lt;svg width="300" height="100"&gt; &lt;mask id="cutouttext"&gt; &lt;rect width="280" height="50" x="0" y="15" fill="white" /&gt; &lt;text x="50%" y="55%" text-anchor="middle" font-size="48"&gt;Hello World&lt;/text&gt; &lt;/mask&gt; &lt;rect width="280" height="50" x="25" y="15" fill="black" mask="url(#cutouttext)" /&gt; &lt;/svg&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Fall back for IE8 and below:</p> <pre><code>&lt;!--[if lt IE 9]&gt; &lt;style&gt; .wrap { color: #ff0000; font-size:48px; text-align: center; padding-top: 10px; height: 90px; } .black { background: black; margin: 0 auto; width:250px; } &lt;/style&gt; &lt;![endif]--&gt; </code></pre> <p>The way it looks in modern browsers:<br> <img src="https://i.stack.imgur.com/dZ3PO.png" alt="enter image description here"><br> and how it looks in IE8 and below:<br> <img src="https://i.stack.imgur.com/zcNDV.png" alt="enter image description here"></p> <p>Documentation:<br> <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Gradients" rel="nofollow noreferrer">MDN SVG Gradients</a><br> <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text" rel="nofollow noreferrer">MDN SVG Text</a><br> <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/mask" rel="nofollow noreferrer">MDN Mask</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload