18.04.2016 Views

Professional JavaScript For Web Developers

javascript for learners.

javascript for learners.

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>JavaScript</strong> in the Browser<br />

❑<br />

❑<br />

CDATA sections are required for inline code. Because SVG is a true XML-based language, it<br />

properly supports CDATA sections and, therefore, requires them when inline code uses special<br />

XML characters.<br />

Uses xlink:href instead of src. In SVG, no src attribute is used on a tag.<br />

Instead, SVG uses the xlink:href attribute to indicate an external file to reference.<br />

<strong>For</strong> example:<br />

<br />

<br />

<br />

<br />

An image of a square and a circle.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

In this code, the two tags are correct for SVG. The first, containing inline code, is surrounded<br />

by a CDATA section so no problems arise if you use special characters; the second uses the xlink:href<br />

attribute to reference an external file.<br />

Tag placement in SVG<br />

Because no area exists in SVG, tags can be placed nearly anywhere. Typically, however,<br />

they are placed:<br />

❑<br />

❑<br />

❑<br />

Immediately after the tag<br />

Inside of the tag<br />

Just before the outermost tag<br />

The tag cannot be placed inside of shapes, such as or , nor can they be<br />

placed inside of filters, gradients, or other appearance-defining tags.<br />

135

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!