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

Can SVG be Directly Embedded within CSS?

Barbara Streisand
Barbara StreisandOriginal
2024-12-17 13:57:22973browse

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>;
}

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>

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!

Statement:
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