html <p>样式代码不起作用

时间:2018-07-09 17:54:39

标签: html css paragraph

试图编写一个简单的网页代码并正在学习html。我不知道为什么我的

的简单样式代码没有进行更改。在下面。

<!DOCTYPE html>
<html>
<head>
<!-- SE copied from old site   -->

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/
font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/topnav-index.css">
<!-- abv css I created myself, just the TopNav bar -->

<style>
<!-- this is for page wide style  -->
<!-- define all paragraph font for main pg   -->
p {
color: red;
text-align: left;
font-family: palatino;
font-size: 16pt;
background-color: #909090;
<!-- margin: 4 prop is top, R, bott, L -->
margin-left: 32px;
margin-top: 30px;
<!-- margin: 20,25,35,40;  -->
padding-left: 12%;
padding-top: 10%;
    } 

</style>
</head>

<body>

<div class="topnav" id="myTopnav">
  <a href="#home" class="active">Home</a>
  <a href="#news">News</a>
  <a href="#contact">Contact</a>
  <a href="#about">About</a>
  <a href="javascript:void(0);" class="icon" onclick="myFunction()">
    <i class="fa fa-bars"></i>
  </a>
</div>

<div style="padding-left:16px">
  <h2>Title</h2>
  <p>Responsive Topnav Example</p>
 </div>

<!--  main content -->
<p>B This site explores the connection between XXX and the
 historical events...</p>

现在,“顶部导航”栏可以工作,但是p文本的格式似乎无任何作用。它位于标题中,并且我理解p(大于/小于符号)充当其自身的特殊容器...

1 个答案:

答案 0 :(得分:3)

在CSS中,您应该使用/ * * /作注释,而不要<!--- -->

p {
    color: red;
    text-align: left;
    font-family: palatino;
    font-size: 16pt;
    background-color: #909090;
    /* margin: 4 prop is top, R, bott, L */
    margin-left: 32px;
    margin-top: 30px;
    /*margin: 20,25,35,40;  */
    padding-left: 12%;
    padding-top: 10%;
}