1.默写html页面的文档结构
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h2></h2>
</body>
</html>
2. 默写html元素的三大通用属性
- id属性:唯一性
- class类属性:多个元素集合
- style属性:设置某个元素的具体样式
- 备注1:id,class:用在css,js中获取一个或多个元素对象
- 备注2:style属性设置的优先级大于class,P标签的优先级小于class
- 三者优先级关系:tag<class<id
3. 理解元素,类,id不同级别的样式规则
对象拿取必须在javascript里面,console.log可获取多种标签,例如以下:
<script>
console.log(window);
console.log(window.document);
console.log(document.URL);
console.log(document.doctype);
console.log(document.documentElement);
console.log(document.head);
console.log(document.charset);
console.log(document.title);
console.log(document.body);
document.body.style.backgroundColor = “wheat”;
console.log(document.styleSheets);
console.log(document.styleSheets[0]);
console.log(document.scripts);
console.log(document.scripts[3]);
console.log(document.currentScript === document.scripts[3]);
</script>const和console.log获取id,class,tag举例:
<script>
const ele = document.getElementById(“title-id”);
// console.log(ele);
const eles = document.getElementsByClassName(“title-class”);
console.log(eles);
console.log(eles[0]);
const p = document.getElementsByTagName(“p”);
console.log(p);
console.log(p[1]);
let x = document.querySelector(“#title-id”);
let y = document.querySelector(“.title-class”);
y = document.querySelectorAll(“.title-class”);
y = document.querySelectorAll(“.title-class.bgcolor”);
console.log(y);
</script>