Question

Where to insert the svg html?

Posted February 15, 2021 235 views
CSS

Thanks for the cursor tutorial! In reviewing your instructions for the custom pointer, I saw that you emphasized that the svg file needs a width and height designated for the custom cursor to be visible. Where does the html that includes the width and height values for the svg go? Thanks!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @juliemadermeersman,

Usually, the size of the SVG is selected when the SVG is created and as such is not needed to be specified.

Having said that, you can change the size of it though just by selecting the img and changing its width or height, again like you could a PNG or JPG.

Let’s say you have an image like so:

<img src="DigitalOcean.svg" alt="DigitalOcean SVG">

if you want to add height or width to is you can simply transform it to:

<img src="DigitalOcean.svg" alt="DigitalOcean SVG"width="500" height="600"> 

Now, if you want to add them as a class, you can do the following

<a href="/" class="logo">
  DigitalOcean
</a>
.logo {
  display: block;
  text-indent: -9999px;
  width: 100px;
  height: 82px;
  background: url(DigitalOcean.svg);
  background-size: 100px 82px;
}

Hope this helps!
Regards,
KFSys