Home > Web Front-end > CSS Tutorial > Can SVG be Directly Embedded within CSS?

Can SVG be Directly Embedded within CSS?

Barbara Streisand
Release: 2024-12-17 13:57:22
Original
901 people have browsed it

Can SVG be Directly Embedded within CSS?

Embedding Inline SVG in CSS

Can you directly embed an SVG definition within CSS? For instance, can you use something like this:

.my-class {
  background-image: <svg>...</svg>;
}
Copy after login

Answer

Yes, you can do that. Here's an example:

body {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'><linearGradient>
Copy after login

The above is the detailed content of Can SVG be Directly Embedded within CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template