Answers for "how to get font without including font file html"

CSS
2

how to add font otf format in html

/*default version*/
@font-face {
	font-family: 'lovelyFont';
	src: url('fonts/lovely_font.eot'); 
	src: 
		local('Lovely Font'),
		local('Lovely-Font'),
		url('fonts/lovely_font.otf') 
		format('opentype');
}
/*bold version*/
@font-face {
	font-family: 'lovelyFont';
	src: url('fonts/lovely_font_bold.eot'); 
	src: 
		local('Lovely Font Bold'),
		local('Lovely-Font-Bold'),
		url('fonts/lovely_font_bold.otf') 
		format('opentype');
	font-weight: bold;
}
/*container element*/
div { font-family: 'lovelyFont', sans-serif; }
/*span elements inside the container div*/
span { font-weight: bold; }
Posted by: Guest on December-05-2020
0

add custom font to html

<style>
  /* include the font here using @font-face */
  @font-face {
    font-family: 'myFontName'; /* this value can be anything you wish - it gets used in the class definition below */
    src: url('path/to/font/myfont.woff'); /* add the file path to your font here */
  }
  
  /* define a class and add the new font */
  #customFont {
   	font-family: myFontName; /* property value must match value in @font-face*/ 
  }
</style>

<div>
  <!-- To use the custom font, simply add your new class to the element -->
  <p id="customFont">Hello, World!</p>
</div>

<!-- Happy coding <3 -->
Posted by: Guest on April-26-2022

Browse Popular Code Answers by Language