Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Codidact Meta!

Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.

Can I use SVG in posts?

+2
−0

Do Codidact posts support SVG (Scalable Vector Graphics) for images and animations?

I can't get either the image upload button or inline SVG to work. Is SVG not supported?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

1 answer

+3
−0

SVG is only supported in an img tag

SVG is only supported inside an HTML <img> tag, or a Markdown image link (which is rendered as an <img> tag behind the scenes).

The image upload button

The image upload button above a post during editing only supports PNG, JPEG, and GIF files. These generally correspond to file extensions .png, .jpg/.jpeg, and .gif.

Inline SVG

Codidact posts support a safe subset of HTML. This means that not all tags are supported. Specifically, the <svg> tag is not supported.

Discussion

If you have reason to believe that either of these could be supported safely, I have started a discussion post Should inline SVG or SVG uploads be supported in posts?

In the meantime an external link is the only available option.

How to include SVG

Still images

In order to include an SVG file in a post, it will need to be hosted online so that you can include its URL. For example, the SVG logo is hosted online by Wikimedia and can be used in a post by including either of the following:

Markdown

![The SVG logo](https://upload.wikimedia.org/wikipedia/commons/4/4f/SVG_Logo.svg)

HTML

<img src="https://upload.wikimedia.org/wikipedia/commons/4/4f/SVG_Logo.svg" alt="The SVG logo">

In the saved post, this is rendered as:

The SVG logo

Animations

Animated SVG files can be included in exactly the same way. For example, an animation I uploaded to GitHub can be used in a post by including either of the following:

Markdown

![Animation of a growing grid of hexagons](https://raw.githubusercontent.com/trichoplax/centered-hexagonal-number-animation/main/animation/centered_hexagonal_numbers.svg)

HTML

<img src="https://raw.githubusercontent.com/trichoplax/centered-hexagonal-number-animation/main/animation/centered_hexagonal_numbers.svg" alt="Animation of a growing grid of hexagons">

Out of consideration for other users, and for accessibility, I recommend hiding animations and clearly labelling them as such, so that each user can choose whether or not to view them. The previous example text will give a large animated image that not everyone will want to see. Either of the following will give the same animated image hidden until a user chooses to view it:

Markdown

<details>
    <summary>
        Animated visualisation
    </summary>

![Animation of a growing grid of hexagons](https://raw.githubusercontent.com/trichoplax/centered-hexagonal-number-animation/main/animation/centered_hexagonal_numbers.svg)
</details>

Note that there is a blank line after the closing </summary> tag, and there is no indentation of the Markdown image link. Both of these are required, otherwise the raw Markdown will be rendered instead of the image. If you prefer consistent indentation and no blank line, you can use the fully HTML version shown below.

HTML

<details>
    <summary>
        Animated visualisation
    </summary>
    <img 
        src="https://raw.githubusercontent.com/trichoplax/centered-hexagonal-number-animation/main/animation/centered_hexagonal_numbers.svg"
        alt="Animation of a growing grid of hexagons"
    >
</details>

In the saved post the image will look like this:

Animated visualisation

Animation of a growing grid of hexagons

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »