“Tambahkan Font Kustom ke HTML” Kode Jawaban

Cara Menambahkan Format Font OTF di 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; }
Dayanaohhnana

Tambahkan Font Kustom ke 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 -->
CoderHomie

Jawaban yang mirip dengan “Tambahkan Font Kustom ke HTML”

Pertanyaan yang mirip dengan “Tambahkan Font Kustom ke HTML”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya