Search code examples
phpcssfont-facecustom-font

PHP and CSS font-face doesn't work


Im currently making a poll website. And i were trying to change the font (to a custom font(font-face)) of the h1 tag but it doesn't work. But changing the color and everything else works. I have also tried changing the tag to p and giving it an id. The custom font works on all other pages but the poll php one.

@font-face {
 font-family: Ubuntu-BI;
 src: url('fonts/Ubuntu-BI.ttf');
}

h1{
 color: #e9e9e9;
 font-family: Ubuntu-BI;
 font-size: 40px;
}

<style>
  <?php include 'css/pollStyle.css'; ?>
</style>
<?php <!-- HERE'S THE REST OF THE CODE

echo "<h1>$title</h1>";  //< Title of the pole

I would really appreciate some help! :)


Solution

  • There is nothing wrong with the CSS itself, the problem must lay in the way it is included. As per miken32 answer you should use a link tag to attach the stylesheet. In theory the way you have specified would work as long as this code was within the <head></head> tags.