Jump to content

Hello! Is there any way to add class to a specific svg?

Recommended Posts


Is there any way I can add a specific class to svg tag?

I try to do that:

	stroke: lightblue;
	stroke-width: 2px;
	right: 0px;
	top: 10px;
	margin:0px 0px 0px 0px;
	padding:0px 0px 0px 0px;

And in the body:

<svg class="svgclass"><line x1="0" y1="0" x2="0" y2="80" /></svg>

This is not work...

(And the svg style is set good, cause when I remove the class from the svg, and change in the css file to svg its all great..)


Thanks! (:

Share this post

Link to post
Share on other sites

There is no reason you can't add a css classname or id to svg element, in fact there are svg css properties specifically for svg usage (just google 'svg css properties').

Share this post

Link to post
Share on other sites

First, your "display:inline-block;" may contradict your other position data. 

Second, the examples I have seen so far put the height and width in the tag definition, as in <svg width="200" height="200" class="svgclass" ></svg> .

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...