<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div {
border: 6px solid red;
}
</style>
</head>
<body>
<div class="box1" style="width: 200px;height: 100px;background-color: pink;"></div>
<script>
const box1 = document.getElementsByTagName("div")[0];
console.log(box1.style.backgroundColor); // pink
console.log(box1.style.border); //没有打印结果,因为这个属性不是行内样式
</script>
</body>