当前位置: 动力学知识库 > 问答 > 编程问答 >

class - Why is my website not recognising classes?

问题描述:

I'm learning to use html. I want the words 'hello welcome to my blog' to appear in courier font. But I want to set it up as a 'class'.

I'm on blogger and I can't seem to get the code working to make this text appear. I'm sure I typed out everything right but for some reason blogspot won't apply the courier font.

However it can read things like h1/h2/Bold/Italic but only when this is directly written before class not in brackets on its own.

<head>

<style>

.font (font-family:courier;)

</ style>

</head>

<body>

<div class="font">

Hello welcome to my blog </div>

</ body>

网友答案:

In CSS syntax you need to wrap properties and values within braces {} not in parenthesis ()

Also you need to close the tags carefully like this </body> Don't use space inside like this </ body>

So you code should look like this-

<head>
    <style>
        .font {
            font-family:courier;
        }
    </style>
</head>

<body>

<div class="font">
    Hello welcome to my blog
</div>

</body>
网友答案:

replace () with {} on the style

<html>
<head>
<STYLE type=" text/css ">
.font{font-family :"Courier New", Courier, monospace}
</style>
</head>
<body>
<div class="font">
`Hello welcome to my blog</div> </body>
</html>

demo for this

分享给朋友:
您可能感兴趣的文章:
随机阅读: