基础
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>style</title><link rel="stylesheet" href="main.css"/><style>h1 {background-color: aquamarine;color: black !important;}.class1{color: red;}#id1{color: blue;}#id2 p{color: royalblue;}#id2 > p{text-decoration-line: underline;}a{}a:hover {color: red;}a:link{color: yellow;}a:visited{color: green;}a:active{color: blue;}body{background-color: aliceblue;background-image: url("../img/demo2.png");background-repeat: no-repeat;background-size: 200px 200px;background-attachment: fixed;background-position-x: center;background-position-y: center;background-position: 10% 10%;}span{font: italic bold 30px "Microsoft YaHei UI";}p{font-size: 16px;width: 120px;color: crimson;line-height: 24px;text-indent: 1em;}</style></head><body><h1 style="background-color: aqua; text-align: center;">111</h1><h1 class="class1">222</h1><h1 id="id1">333</h1><div id="id2"><p>p1</p><div><p>p2</p></div></div><a href="">百度</a></body>
</html>
计时器
<h1 id="clock"></h1>
<script>const formatTime = n => n < 10 ? '0' + n : n;function updateClock(){const date = new Date();const hours = formatTime(date.getHours());const minutes = formatTime(date.getMinutes());const seconds = formatTime(date.getSeconds());const clock = document.getElementById("clock");clock.textContent = `${hours}:${minutes}:${seconds}`;}setInterval(updateClock,1000);
</script>