W3Schools.com (2024)

SVG (Scalable Vector Graphics)

SVG defines vector-based graphics in XML, which can be directly embedded in HTML pages.

SVG graphics are scalable, and do not lose any quality if they are zoomed or resized:

SVG is supported by all major browsers.

What is SVG?

  • SVG stands for Scalable Vector Graphics
  • SVG is used to define vector-based graphics for the Web
  • SVG defines graphics in XML format
  • Each element and attribute in SVG files can be animated
  • SVG is a W3C recommendation
  • SVG integrates with other standards, such as CSS, DOM, XSL and JavaScript

The <svg> Element

The HTML <svg> element is a container for SVG graphics.

SVG has several methods for drawing paths, rectangles, circles, polygons, text, and much more.

SVG Circle

Example

<!DOCTYPE html>
<html>
<body>

<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>

</body>
</html>

Try it Yourself »

SVG Rectangle

Example

<svg width="400" height="120">
<rect x="10" y="10" width="200" height="100" stroke="red" stroke-width="6" fill="blue" />
</svg>

Try it Yourself »

SVG Rectangle with Opacity and Rounded Corners

Example

<svg width="400" height="180">
<rect x="50" y="20" rx="20" ry="20" width="150" height="150"
style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg>

Try it Yourself »

SVG Star

Example

<svg width="300" height="200">
<polygon points="100,10 40,198 190,78 10,78 160,198"
style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;" />
</svg>

Try it Yourself »

SVG Gradient Ellipse and Text

Example

<svg height="130" width="500">
<defs>
<linearGradient id="grad1">
<stop offset="0%" stop-color="yellow" />
<stop offset="100%" stop-color="red" />
</linearGradient>
</defs>
<ellipse cx="100" cy="70" rx="85" ry="55" fill="url(#grad1)" />
<text fill="#ffffff" font-size="45" font-family="Verdana" x="50" y="86">SVG</text>
Sorry, your browser does not support inline SVG.
</svg>

Try it Yourself »

Differences Between SVG and Canvas

SVG is a language for describing 2D graphics in XML, while Canvas draws 2D graphics, on the fly (with JavaScript).

SVG is XML based, which means that every element is available within the SVG DOM. You can attach JavaScript event handlers to SVG graphics.

In SVG, each drawn shape is remembered as an object. If attributes of an SVG object are changed, the browser can automatically re-render the shape.

Canvas is rendered pixel by pixel. In canvas, once the graphic is drawn, it is forgotten by the browser. If its position should be changed, the entire scene needs to be redrawn, including any objects that might have been covered by the graphic.

Comparison of SVG and Canvas

The table below shows some important differences between Canvas and SVG:

SVGCanvas
  • Resolution independent
  • Support for event handlers
  • Good text rendering capabilities
  • Slow rendering if complex
  • Not suited for game applications
  • Resolution dependent
  • No support for event handlers
  • Poor text rendering capabilities
  • You can save the resulting image as .png or .jpg
  • Well suited for graphic-intensive games

SVG Tutorial

To learn more about SVG, please read our SVG Tutorial.


W3schools Pathfinder

Track your progress - it's free!

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.

W3Schools.com (2024)

FAQs

Why do people avoid W3Schools? ›

There is a LOT of working constantly happening in the worlds of HTML, CSS, and JavaScript, and if a resource doesn't keep up, it is a detriment to the programming world, not a benefit. Using W3Schools to learn something is a waste of time, some topics are outdated and it lacks the rigor that you'll find on MDN.

Is W3Schools good enough? ›

W3schools is good for a quick reference point if you're in the middle of coding something and want to find out a specific function or whatever. If you want to learn advanced code I would avoid W3schools however w3schools is a good free resource for the average programmer.

Is W3Schools certification legit? ›

W3Schools is Trusted by Top Companies

Our certificates are recognized and valued by companies looking to employ skilled developers.

Is W3Schools a reliable source? ›

Their ... | Hacker News. Nobody denies that W3Schools is a terrible place to learn how to program. Their examples are outdated, insecure, and don't really explain why things work in a certain way.

Which is better W3Schools or codecademy? ›

Of the two, Codecademy has a simpler structure. You can easily find the topic you want and start learning. Its fixed pricing plans are also easier to understand. In addition, the biggest issue with W3Schools is the ads that keep popping up as you learn.

Who is behind W3Schools? ›

It is run by Refsnes Data in Norway. It has an online text editor called TryIt Editor, and readers can edit examples and run the code in a test environment.

Can I get a job with a W3Schools certificate? ›

Becoming certified by W3Schools is great proof to show to employers and makes your resume stand out among other candidates.

How does w3school make money? ›

Through ads : through ads alone they will earn alot in w3schools. They would earn nearly 1–2lacks per day in ads alone. Through donation:. Many people who completed their courses in w3schools, after few years , they would donate some money for the growth of the site .

Is sololearn better than W3Schools? ›

Neither are necessarily better than the other because they both show their curriculum in different ways. I think Sololearn is better for experimentation and First-time learning while w3 schools is better for reference.

How much does W3Schools cost? ›

Both My Learning and W3Schools Public Profile are completely free of charge, however there are available upgrade plans that can enhance your learning experience.

Is W3Schools enough for SQL? ›

Basically the title. Not only Select Star SQL misses many basic SQL operations, but its explanations are both unnecessarily complicated and miss lots of details.

Can you learn from W3Schools? ›

We create simplified and interactive learning experiences. Learning web development should be easy to understand and available for everyone, everywhere! W3Schools is a school for web developers, covering all the aspects of web development: HTML Tutorial.

Is W3Schools good for kids? ›

Who can use W3Schools? W3Schools is accessible to everyone, from beginners to more experienced developers. It serves as a valuable resource for both groups, often used as a reference tool. It is particularly suitable for middle and high school students, aligning well with their educational needs and curriculums.

Is W3Schools popular? ›

W3schools is a great resource for looking up how to write a specific piece of code, but it doesn't have the flow or continuity that the other courses do.

Is W3Schools a good place to learn SQL? ›

"Perfect e-learning course for beginners. The training is very well structured together with quizes after almost every lesson. Great job!

Are there any websites like W3Schools? ›

stack overflow is the largest, most trusted online community for developers to learn, share​ ​their programming ​knowledge, and build their careers. learn to code in python, c/c++, java, and other popular programming languages with our easy to follow tutorials, examples, online compiler and references.

Top Articles
SQL Server IN vs EXISTS
property
Metra Union Pacific West Schedule
Citibank Branch Locations In Orlando Florida
Ghosted Imdb Parents Guide
Phcs Medishare Provider Portal
Stadium Seats Near Me
Cash4Life Maryland Winning Numbers
Botanist Workbench Rs3
San Diego Terminal 2 Parking Promo Code
Overzicht reviews voor 2Cheap.nl
Costco in Hawthorne (14501 Hindry Ave)
How to Watch Braves vs. Dodgers: TV Channel & Live Stream - September 15
Our History | Lilly Grove Missionary Baptist Church - Houston, TX
Hssn Broadcasts
Craigslist Pets Southern Md
Troy Athens Cheer Weebly
Drago Funeral Home & Cremation Services Obituaries
Shreveport Active 911
Arre St Wv Srj
Locate At&T Store Near Me
Wgu Academy Phone Number
Blue Rain Lubbock
Poe Str Stacking
Ups Drop Off Newton Ks
Mega Personal St Louis
25 Best Things to Do in Palermo, Sicily (Italy)
Sadie Sink Reveals She Struggles With Imposter Syndrome
Foolproof Module 6 Test Answers
2000 Ford F-150 for sale - Scottsdale, AZ - craigslist
Ou Football Brainiacs
Vht Shortener
130Nm In Ft Lbs
Alternatieven - Acteamo - WebCatalog
Salemhex ticket show3
+18886727547
Ilabs Ucsf
Kaiserhrconnect
Fandango Pocatello
Kstate Qualtrics
Suspect may have staked out Trump's golf course for 12 hours before the apparent assassination attempt
Mp4Mania.net1
Free Robux Without Downloading Apps
Can You Buy Pedialyte On Food Stamps
Kornerstone Funeral Tulia
Gary Lezak Annual Salary
Mytime Maple Grove Hospital
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
Noh Buddy
Spurs Basketball Reference
House For Sale On Trulia
Game Like Tales Of Androgyny
Latest Posts
Article information

Author: Kareem Mueller DO

Last Updated:

Views: 6357

Rating: 4.6 / 5 (66 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Kareem Mueller DO

Birthday: 1997-01-04

Address: Apt. 156 12935 Runolfsdottir Mission, Greenfort, MN 74384-6749

Phone: +16704982844747

Job: Corporate Administration Planner

Hobby: Mountain biking, Jewelry making, Stone skipping, Lacemaking, Knife making, Scrapbooking, Letterboxing

Introduction: My name is Kareem Mueller DO, I am a vivacious, super, thoughtful, excited, handsome, beautiful, combative person who loves writing and wants to share my knowledge and understanding with you.