Generate unique icons and fonts without relying on external sources or linking them directly in the HTML code

Is it possible to utilize content in CSS for generating custom icons without the need for any dependencies or CDN paths embedded in the HTML? I have a single-page application where I want to avoid adding external CSS. Can anyone offer guidance on achieving this?

Answer №1

If you want to keep all content within the stylesheet, consider using a data url.

For instance, check out this straightforward example:

div::before {
  content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='45'%3E%3Cpath d='M10 10h60' stroke='%2300F' stroke-width='5'/%3E%3Cpath d='M10 20h60' stroke='%230F0' stroke-width='5'/%3E%3Cpath d='M10 30h60' stroke='red' stroke-width='5'/%3E%3C/svg%3E");
  width: 20vw;
  height: 20vw;
}
<div></div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Displaying iFrame Border in React Native WebView

When attempting to dynamically add YouTube videos to my React Native app, I decided to utilize a combination of WebView and iFrame due to the incompatibility of the current react-native-youtube component with RN 16+. Although this solution works, the ifram ...

Role-based dynamic layout

I am currently working on a website that requires user login functionality. To achieve this, I am utilizing materialise-css and Angularjs for the front-end development, while the back-end is powered by Java-Hibernate (as Spring is not an option in my case) ...

Creating a circular price display using CSS:

Below is the code snippet that I am working with: .special-price { text-align: center; background-color: #2e566e; } .special-price .offer { border-radius: 50%; background-color: #56c243; color: #fff; font-weight: 700; font-size: 18px; h ...

Changing the Image Path According to the Device's Retina Ratio

I'm currently setting up a website for a photographer and working on creating a gallery. To streamline the process, I have automated many aspects such as file names, paths, widths, lightbox classes, etc. All I have to do in the HTML is write an <a ...

What's the best way to make the background image fill the entire page and have the buttons perfectly centered on top of the image?

I am currently working with Angular version 13 and have included the following CSS code. .image{ min-height: 100vh; background-position: center center; background-repeat: no-repeat; background-size: cover; back ...

jQuery: Function is not running as expected

I'm facing a challenge in executing a function twice, and I'm having trouble identifying the issue. Check out my JSFiddle at the following link: http://jsfiddle.net/g6PLu/3/ Javascript function truncate() { $(this).addClass('closed&apo ...

Applying a CSS Class to EditorFor in an ASPX C# view engine is not supported

I have created a user interface using basic HTML attributes and the Bootstrap framework. I am now looking to integrate Html.EditorFor() in place of <input type="text" class="form-control" />. This is how I attempted to add it: <%= Html.EditorFo ...

When you click anywhere on the page, JavaScript's method __dopostback is triggered

I'm encountering an issue in my asp.net application where I have an html table. Specifically, when a user clicks on a td element within the table, I use JavaScript to store the id of that td element in a hidden field. Afterwards, I trigger __dopostbac ...

Make the div's width equal to the width of the table inside

In one of my table cells, I have the following structure: <td> <div class="table-wrapper"> <table class="inner-table"> <!--content--> </table> <div> </td> I added the div so I coul ...

iPhone 5s landscape mode causing issues with media query

I have been testing a media query that looks like this: @media screen and (max-width: 600px) { .blah { font-size: 1.25rem; } } When I test this in responsive mode on browser dev tools, everything looks great. I can see all the changes as I resize ...

Avoiding the duplication of a random number in a for loop

My PHP for loop generates a random number. for($i = 0; $i < mysql_num_rows($query); $i++) { $random = rand(000, 999); } I am looking to ensure that the random results from the for loop are never repeated. The loop runs 999 times and I want each result ...

Adjust and place div in relation to image with full height perspective

Looking for a better headline... On my non-mobile device page, I want to ensure that a large image always fits the window height. Take a look at the page. This is how I've set it up: #background{ position:absolute; background-color:#F00; ...

an occurrence of an element being rendered invisible, within an instance of an element being rendered as flexible,

I am trying to create a button that will show a list of elements. Within this list, there is another button that can be used to either close the list or hide it entirely. However, for some reason, my code is not functioning properly. let btn1 = documen ...

Issue with background color not being displayed in print preview on Internet Explorer

How can I ensure that IE will display the circles when printing? I am currently using this code: <li ng-repeat="items in ferdigheter">{{ items.title}} <div class="circles"> <div class="circle" ng-repeat="a in thisnumber(items.stars)"&g ...

Eliminate the CSS triggered by a mouse click

Having some difficulty toggling the switch to change the background color. Struggling with removing the applied CSS and getting it to toggle between two different colored backgrounds. Code Sample: <!Doctype html> <html lang="en"> <head> ...

Using CSS for multiple background images can be achieved by including one image in a stylesheet and another image

Is it possible to have two background images using a combination of CSS and inline styling? #example1 { background-image: url(top.gif), url(bottom.gif); ... } For instance, one image may be dynamically defined within the element itself using an inlin ...

What could be causing WebKit to fail in accurately redrawing this text?

I am experiencing a unique issue with the WebKit renderer. It seems that when a text node contains a descender or ascender that extends beyond the selection box of the text node, and the position of the text node changes, WebKit fails to repaint the correc ...

Conceal zoom-in function in video element for Edge and Internet Explorer

I'm trying to get rid of the zoom in control on the video tag that only shows up in Edge and Internet Explorer. I've attached a snapshot for reference. I've searched for a solution but haven't had any luck. https://i.sstatic.net/7Lx8k. ...

Restricting the amount of visible

I have a Q&A section with multiple stacked boxes. I noticed that opening all the boxes made the page too long, so I'm exploring if JavaScript or jQuery can help limit the number of active boxes. $(document).ready(function() { $(".faqOuter").c ...

Guide on creating concentric circle nested diagram with HTML and CSS

I created the illustration, but I'm unsure how to insert text into it. I'd like to place the text inside the circular shape. .shapeborder { border: 1px solid black; } .circle { border-radius: 50%; } .outer { background-color: blue; ...