HTML和CSS编程

AGe*_*eek 1 html css

我正在使用以下代码:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <style type="text/css">
    td.one
    {
      align="center";
      colspan="3";
      bgcolor="lightgrey";
      style="font-size:15px;font-weight:bold;"
    }
  </style>
</head>

<body>
  <table border="1" cellspacing="1" cellpadding="1" width="100%">
   <tr>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td class="one">Session 1</td>
     <td class="one">Session 1</td>
   </tr>
</body>
Run Code Online (Sandbox Code Playgroud)

这个CSS不适合我.我想制作课程,因此不同的<td>元素会有不同的外观.

Ric*_*dle 11

您在样式表中使用HTML属性名称和语法,而您需要使用CSS名称和语法:

<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style type="text/css">
            td.one
            {
                text-align: center;
                /* There's no way to do colspan="3" in CSS */
                background-color: lightgrey;
                font-size: 15px;
                font-weight:bold;
            }
        </style>
    </head>

<body>
  <table border="1" cellspacing="1" cellpadding="1" width="100%">
   <tr>
     <td> </td>
     <td> </td>
     <td class="one">Session 1</td>
     <td class="one">Session 1</td>
   </tr>
</body>
Run Code Online (Sandbox Code Playgroud)