1.什么是结构、样式、行为相分离?这样做的好处是什么?
Web包含三个层次: HTML、CSS和JavaScript(三者各司其职,互不干涉)
- HTML——负责网页结构
- CSS——负责网页外观样式
- JavaScript——负责交互行为
三者分离的好处:
- 可以复用
- 便于维护和修改
- 利于团队开发
2.什么是语义化?为什么要语义化?
语义化意味着顾名思义,是指合理使用有意义的标签来创建页面结构,让人字面上就可以知道这个标签的作用。
语义化的原因:
- 去掉或丢失样式的时候能够让网页呈现清晰的结构
- 有利于SEO(搜索引擎检索),提升站内排名
- 语义化更具有可读性,便于团队开发和维护
- 方便其他设备解析(如屏幕阅读器、盲人阅读器、移动设备)以意义大方式来渲染网页。
3.什么是CSS?它的特点有哪些?
CSS全称是Cascading Style Sheets(层叠样式表或级联样式表),主要是对HTML标记的内容进行丰富的装饰,并将网页样式与网页结构分离的一种样式设计语言。
CSS的特点:
- 层叠性
在权重(优先级)相同的情况下,同一个标签的样式发生冲突,最后声明的样式会将之前声明的样式覆盖掉。 - 继承性
子元素会自动拥有父元素的某些CSS属性,文本类的属性会被继承。 - 优先级
指不同类别样式之间的权重比较。
优先级顺序:!important>style>id>class>元素>通配符