There are two kinds of watermarks regularly used in web development:

  1. Page watermarks, used to enhance brand awareness.
  2. Image and video watermarks, used to declare ownership and protect copyright.

This article shows how to create page watermarks: specifically, text (or logos) on a diagonal.

SVG Text Watermarks

I’ve previously tackled the issue of presenting multiple diagonal text elements in page backgrounds. My earlier solution used PNG images, but it’s much more effective to create a SVG with the <pattern> element I introduced last week.

A single-line example would be:

<svg xmlns="" width="100%" height="100%">
        <pattern id="textstripe" patternUnits="userSpaceOnUse" width="400" height="200" patternTransform="rotate(-45)">
            <text y="30" font-family="Avenir" font-size="40">DUDLEY STOREY</text>
<rect width="100%" height="100%" fill="url(#textstripe)" />

I’ll discuss the <text> element in more detail in a future article; for now, note that the <pattern> area is wider than it is high, and that the text has been moved down slightly. This produces:


Adding Subtext

Introducing another line into the watermark between the previous text is achieved by adding a second pattern, with a third merging both patterns into one:

<svg xmlns="" width="100%" height="100%">
<style type="text/css">
    text { fill: gray; font-family: Avenir; }
        <pattern id="twitterhandle" patternUnits="userSpaceOnUse" width="400" height="200">
            <text y="30" font-size="40" id="name">@dudleystorey</text>
        <pattern xlink:href="#twitterhandle">
            <text y="120" x="200" font-size="30" id="occupation">web developer</text>
        <pattern id="combo" xlink:href="#twitterhandle" patternTransform="rotate(-45)">
              <use xlink:href="#name" />
            <use xlink:href="#occupation" />
<rect width="100%" height="100%" fill="url(#combo)" />

The result is the initial state of the background image you see at the top of this article.

By building up patterns in this way, it’s possible to construct complex backgrounds from basic components with relatively little effort… and the text remains completely live and editable, as you can see by using the form built into the demo.

Note that the code above has been kept clean by following a few SVG best practices:

  1. Presentation attributes have been turned into CSS, where appropriate.
  2. The second and third patterns reference the first via an xlink, inheriting the original’s patternUnits, width and height.
  3. The transform has been left for the last pattern, rather than repeating the rotation.

The demo at the top of this page makes the text dynamic; under normal circumstances, your desired watermark text (and choice of font, color, etc) would be hard-coded into the SVG, which would then be referenced as a background-image.

Enjoy this piece? I invite you to follow me at to learn more.
Check out the CodePen demo for this article at