XML technologies / SVG / Creating simple SVG graphics / Creating and formatting simple text / Adding page banner text

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

The page banner needs two texts, created with the <text> tag. To put them on top of the graphic, append them at the end before the </svg> tag. The first contains “SVG”, the second “Scalable Vector Graphic”. Their source code and formatting are:

<text id="ueberschrift" x="536" y="90" style="font-family:Arial Black;font-size:100;stroke-width:1;stroke:rgb(0,0,0);fill:rgb(255,255,255);">SVG</text>
<text id="unterschrift" x="244" y="90" style="font-family:Arial Black;font-size:39;stroke-width:1;stroke:rgb(0,0,0);fill-opacity:0.5;fill:rgb(0,0,0);">Scalable Vector Graphic</text>

The table explains the formatting specifications used.

Table: Important formatting settings for the text tag.

Formatting

Description

font-family

Sets the font, which displays correctly only if installed on the viewer’s computer. As in HTML stylesheets, list alternatives separated by commas, enclosing names with spaces in single quotes. For example, specify Helvetica as an alternative with style="font-family:'Arial Black',Helvetica".

font-size

Sets font size in pixels.

stroke-width

Sets outline width.

stroke

Sets outline color.

fill-opacity

Sets fill opacity from 0 (fully transparent) to 1 (fully opaque). The example gives the subtitle 50% transparency.

fill

Sets the text’s fill color.

Note:
Wherever colors are accepted, use color names or RGB values. For example, fill:red or fill:rgb(255,0,0) fills an element red. More information on colors, gradients and patterns appears in Filters, transformations and gradients.

Internet Explorer displays these additions as follows:

Result of the page banner’s first text elements

Figure: Result of the page banner’s first text elements.

   

 

 

 

back to top