Bagaimana cara memindahkan semua gaya saya di html ke css? Saat saya salin dan tempel, itu tidak berfungsi dengan baik.

<!DOCTYPE html>
<html lang="en">



<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table,
        td,
        th {
            border-bottom: 1px solid #c4dcf3;
            border-collapse: collapse;
            padding: 5px;
        }
        
        tfoot {
            text-align: left;
        }
        
        tbody tr:nth-child(odd) {
            background-color: #eef7ff;
        }
    </style>


</head>

<body>
    <table>
        <thead style="background-color: #427fef;">
            <tr>
                <th>Country</th>
                <th>OrderID</th>
                <th>Order Amount</th>
            </tr>

        </thead>

        <tbody>

            <tr>
                <td>USA</td>
                <td>1000</td>
                <td>$1,300</td>
            </tr>

            <tr>
                <td>USA</td>
                <td>1001</td>
                <td>$700</td>
            </tr>
            <tr>
                <td>CA</td>
                <td>1002</td>
                <td>$2,000</td>
            </tr>

            <tr>
                <td>CA</td>
                <td>1003</td>
                <td>$1,000</td>
            </tr>
        </tbody>

        <tfoot>
            <tr style="background-color: #427fef;">
                <th>Total</th>
                <th align="center" colspan="2">$5,000</th>
            </tr>
        </tfoot>
    </table>




</body>

</html>
-4
Forca Naveen 11 Mei 2021, 19:32

1 menjawab

Jawaban Terbaik
i just link .css file within header

<!DOCTYPE html>
<html lang="en">



<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="mystyles.css">
    <title>Document</title>
   


</head>

<body>
    <table>
        <thead style="background-color: #427fef;">
            <tr>
                <th>Country</th>
                <th>OrderID</th>
                <th>Order Amount</th>
            </tr>

        </thead>

        <tbody>

            <tr>
                <td>USA</td>
                <td>1000</td>
                <td>$1,300</td>
            </tr>

            <tr>
                <td>USA</td>
                <td>1001</td>
                <td>$700</td>
            </tr>
            <tr>
                <td>CA</td>
                <td>1002</td>
                <td>$2,000</td>
            </tr>

            <tr>
                <td>CA</td>
                <td>1003</td>
                <td>$1,000</td>
            </tr>
        </tbody>

        <tfoot>
            <tr style="background-color: #427fef;">
                <th>Total</th>
                <th align="center" colspan="2">$5,000</th>
            </tr>
        </tfoot>
    </table>




</body>

</html>



and your mystyles.css is like 

 table,
        td,
        th {
            border-bottom: 1px solid #c4dcf3;
            border-collapse: collapse;
            padding: 5px;
        }
        
        tfoot {
            text-align: left;
        }
        
        tbody tr:nth-child(odd) {
            background-color: #eef7ff;
        }
0
Marynathan Judson 11 Mei 2021, 17:18