html5基础---h5特性

1. attr和prop

· 什么是attribute,什么是property

​ html标签的预定义和自定义属性我们统称为attribute
​ js原生对象的直接属性,我们统称为property

· 什么是布尔值属性,什么是非布尔值属性

​ property的属性值为布尔类型的 我们统称为布尔值属性
​ property的属性值为非布尔类型的 我们统称为非布尔值属性

· attribute和property的同步关系

​ 非布尔值属性:实时同步
​ 布尔值属性:
​ property永远都不会同步attribute
​ 在没有动过property的情况下
​ attribute会同步property
​ 在动过property的情况下
​ attribute不会同步property

· 用户操作的是property
· 浏览器认的是property

2. H5小功能

· class --> 新增classList

​ dom对象新增classList属性与add remove toggle方法来操作html中的类。

testNode.classList.add()

· dataset: 自定义属性(限制 data-x-y)的property

testNode.dataset.testProp = '' (data-test-prop)

· html属性 --> 内容可编辑

contenteditable="true"


3. h5和h4的区别

· <!DOCTYPE html>

​ H5无需引入dtd标准文件,声明简化,但也不能省略,否则会触发怪异模式。详见文件

· 根元素

<html xmlns="http://www.w3.org/1999/xhtml"> 简化为 <html></html>

·MINE类型

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 简化为 <meta charset="UTF-8">,MINE类型声明放在http协议中,以Content-Type:text/html的方式。

· 语义化标签
<hgroup></hgroup>
<header></header>
<nav></nav>
<main></main>
<section></section>
<footer></footer>
<article></article>
<aside></aside>
原文地址:https://www.cnblogs.com/GisNicer/p/14760598.html