Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

html - Font won't show up?

 <head>
    <body style="background-color:black;">
      <style>
        @font-face {
      font-family: 'Font';
      src: url('Font.ttf') format('truetype');
    }
        h1 {
      font-family: 'Font';
       color: white;
          font-size: 35px;
    }
           a {
      font-family: 'Font';
       color: #0040ff;
             font-size: 35px;
    }
        a { text-decoration: none; }
    a:visited { text-decoration: none; }
    a:hover { text-decoration: none; }
    a:focus { text-decoration: none; }
    a:hover, a:active { text-decoration: none; }
        </style>
      <title>test</title>
      <h1 style=font-size:35px>test<h1>
        <div>
    <a href="test.html">test</a>
          </div>
          </body>

I have no idea what's wrong

question from:https://stackoverflow.com/questions/65850451/font-wont-show-up

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This code is really bad written. You are missing the end of your </head> tag and your html text is somewhere between the <head>, <styles> and the end of the </body> written. Here is how it should be, but keep in mind that this is not a good solution, you should write your CSS code externally.

<head>
  <style>           
    body{ background-color:black;}
            @font-face {
            font-family: 'Font';
            src: url('Font.ttf') format('truetype');
            }
            h1 {
            font-family: 'font';
            color: white;
                font-size: 35px;
            }
            a {
            font-family: 'Font';
            color: #0040ff;
                    font-size: 30px;
            }
            a { text-decoration: none; }
            a:visited { text-decoration: none; }
            a:hover { text-decoration: none; }
            a:focus { text-decoration: none; }
            a:hover, a:active { text-decoration: none; }
                
      </style>
  <title>test</title>
  </head>
    <body>  
        <h1 style=>test<h1>
        <div>
            <a href="test.html">test</a>
        </div>
    </body>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...