WBE BLOG
Background Повернутись

Using SVG-format in web-design

Share:

Scalable Vector Graphics or shortly SVG is widely spread and its main advantage is to save qualities during scaling.

Advantages of SVG-format and where to use it

Apart from, SVG-format is very convenient for using during development under retina.
But it is not the one plus for SVG. Between advantages you can also highlight:
- Not big size, comparative to others. SVG pictures are smaller in size than raster image and it definitely positively influence on speed of downloading the site.
- An opportunity to access to separate elements through DOM, It allows to edit some separate parts of the picture or the whole image with the help of CSS. Also it gives an opportunity to link on them some events with the help of Java Script and animate.
- The text in SVG-format remains text and accordingly index by searching systems.
- It is possible to reuse the image and its parts.
- Good support by browsers tags <svg> </ svg> (look at the picture)

 

svg-caniuse.png

Ways of integration in HTML layout

Depending on for what you need image in SVG-format, you can use different ways of pasting SVG-image in HTML.

The first and the easiest way is to use the image as background (css-characteristic, background-image). But in this case, apart from background image in high quality, you won’t get anything more.

The second way is to paste images with the help of tag <img>. Analogically to background image we receive just inly the high-quality image. If we want to have an access to parts of the image, edit it or animate it, you should use the direct pasting of the SVG code using the <svg> </ svg> tag.

The work with the text in SVG-format

As was mentioned above, one of the advantages in SVG-format is its indexation.

Although one more plus is an opportunity of individual stylization that is impossible to get only with the help of CSS.

For example, let’s look on changing the text orientation. Vertical text is probably the most elementary thing to do. The more interesting it will be to put text on ascending (it can be realized with the help of <textpath> </ textpath> ):

текст-по-кривой.png   
<svg width="100%" height="500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" >
        <defs>  
            <path id="textline" fill="none" stroke="none" d="M80,100 Q126,56 97,155 T356,46 "/>  
        </defs>
        <use xlink:href="#textline"/>  
        <text y="100" x="10">  
            <textPath xlink:href="#textline" font-size="30">  
            Этот текст наложен на кривую
            </textPath>  
        </text>
   </svg>

Make a stroke of the text or gradient fill

gradient.png

<svg  width="100%" height="500" xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" >
        <defs>  
            <path id="textline" fill="none" stroke="none" d="M80,100 Q126,56 97,155 T356,46 "/>  
            <linearGradient id="gradient" gradientTransform="rotate(-10)" gradientUnits="objectBoundingBox">
                               <stop offset="0" stop-color="#32d6ff"></stop>
                               <stop offset="65%" stop-color="#2e49f7"></stop>
                               <stop offset="75%" stop-color="#5a28ef"></stop>
            </linearGradient>
        </defs>
       
            <use xlink:href="#textline"/>  
            <text y="100" x="10" fill="url(#gradient)">  
                <textPath xlink:href="#textline" font-size="30">  
                Этот текст наложен на кривую
                </textPath>  
            </text>
       

The example of using SVG-format in WBE logotype

When creating the blog and the site of WBE, it was decided to make the company logo with the text in SVG format for indexing and for speeding up page loading.

For a variant of the logo on the blog page, it was necessary to fill the parts of the letters with different colors. Using SVG is an excellent solution to this problem:

 

лого_блог.png

 

To achieve this effect, we used a kind of mask of polygons of different colors that we put on the text.

With the help of the <clipPath> </ clipPath>  tag, we pointed out  which word to apply the fill. Next, they built the polygons that were required, and using the clip-path property, specify which words to apply the fill.

Actually, here it is the code:

<g id="imagebot_3">
    <clipPath id="text1">
        <text xml:space="preserve" transform="translate(-155.348 82.0046) matrix(6.49327 0 0 6.49327 -1055.05 -1348.4)" font-family="Conv_raleway-semibold" font-size="14" y="207.5" x="193.96" id="imagebot_4">
            <tspan id="imagebot_5" text-anchor="start" dy="0em" x="193.96">WBE</tspan>
        text>
     </clipPath>
    <polygon points="50,0 50,106 127,106 78,0 " fill="#143145" clip-path="url(#text1)" />  
    <polygon points="127,106 78,0 270,0 270,106" fill="#8a98a2" clip-path="url(#text1)" />
</g>
<g id="imagebot_1">
    <clipPath id="text2">
        <text xml:space="preserve" transform="translate(-155.348 82.0046) matrix(8.60265 0 0 8.60265 -2113.6 -1307.72)"font-family="Conv_Intro W01 Thin" font-size="14" y="160.5" x="263.75" id="imagebot_2">
            <tspan id="imagebot_6" text-anchor="start" dy="0em" x="262.75">BLOG</tspan>
        </text>
 </clipPath>
<polygon points="0,70 0,160 130,160 130,0 " fill="#848487" clip-path="url(#text2)" />  
<polygon points="130,160 130,0 350,0 350,40 300,50 280,160" fill="#8a98a2" clip-path="url(#text2)" />  
<polygon points="300,50 280,160 350,160" fill="#848487" clip-path="url(#text2)" />
</g>

лого_сайт.png

Analogical technology was used to logotype on the site WBE, but there were used gradients for filling up:

<defs>
    <linearGradient id="gradient1" gradientTransform="rotate(-10)" gradientUnits="objectBoundingBox">
                   <stop offset="0" stop-color="#265684"></stop>
                    <stop offset="65%" stop-color="#032660"></stop>
                    <stop offset="75%" stop-color="#5592af"></stop>
               </linearGradient>
      <linearGradient id="gradient2" gradientTransform="rotate(-15)" gradientUnits="objectBoundingBox" >
                     <stop offset="0" stop-color="#88a1b3"></stop>
                      <stop offset="5%" stop-color="#b0c2ce"></stop>
                       <stop offset="20%" stop-color="#628197"></stop>
               </linearGradient>
      <linearGradient id="gradient3" gradientTransform="rotate(0)" gradientUnits="objectBoundingBox">
                         <stop offset="0" stop-color="#001652"></stop>
                        <stop offset="50%" stop-color="#003e6b"></stop>
               </linearGradient>
</defs>

<g id="imagebot_3">
        <clipPath id="text1">
            <text xml:space="preserve" transform="translate(-115.348 82.0046) matrix(6.49327 0 0 6.49327 -1055.05 -1348.4)" font-family="Raleway-semibold" font-size="10" y="207.5" x="193.96" id="imagebot_4">
                 <tspan id="imagebot_5" text-anchor="start" dy="0em" x="193.96">WBE</tspan>
            </text>
        </clipPath>
    <polygon points="90,0 90,90 160,90 160,0 " fill="url(#gradient1)" clip-path="url(#text1)" />  
    <polygon points="160,90 160,0 240,0 240,90" fill="url(#gradient2)" clip-path="url(#text1)" />
     <polygon points="200,90 200,0 240,0 240,90" fill="url(#gradient3)" clip-path="url(#text1)" />
</g>

 

Share: