Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
41
rated 0 times [  42] [ 1]  / answers: 1 / hits: 33810  / 8 Years ago, mon, september 26, 2016, 12:00:00

I need to complete a site without using CSS at all.



Every thing goes right but i don't know how to change my font-family with pure JS.



Does anyone know how it is possible to import fonts using JS only?



Thanks!


More From » fonts

 Answers
26

I would suggest using Google's Webfontloader, it's incredibly simple to use:



WebFont.load({
google: {
families: ['Droid Sans', 'Droid Serif']
}
});


Which would allow you to use the massive web font library hosted by google here, without needing to explicitly specify the CSS. You can use custom fonts as well if you're willing to use a style tag or a .css file (or you can inject the @font-face via javascript.) There are other web font providers that work with the Webfontloader, just look on the github page.



If you're interested in learning how to do this manually in javascript, any query on injecting CSS via javascript will sort you, but, that's still technically using CSS. Not sure if this/that is what you want.


[#60595] Friday, September 23, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
destiniemartinac

Total Points: 92
Total Questions: 106
Total Answers: 111

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
destiniemartinac questions
Thu, Oct 28, 21, 00:00, 3 Years ago
Sat, Mar 13, 21, 00:00, 3 Years ago
Wed, May 20, 20, 00:00, 4 Years ago
;