--本笔记中英混合,专业名词尽量不翻译,免得误解,如果不习惯,就不用往下看了,走好不送。

第一章 基础

人类的好奇心总是促使我们捣鼓,捣鼓是最好做有效的学习CSS的方法

In this chapter you will learn about
• Structuring your code
• The importance of meaningful documentation
• Naming conventions
• When to use IDs and class names

• Microformats
• Different versions of HTML and CSS
• Document types, DOCTYPE switching, and browser modes

 

这一章我们将学习

- 结构化代码

- 有意义文档的重要性

- 命名规范

- 使用ID和Class的时机

- 微格式

- HTML和CSS的不同版本

- 文档类型, DOCTYPE 切换, 浏览器模式

 

结构化代码

有意义且结构良好的HTML对简化开发具有重要作用

As well as being easy for humans to understand, meaningful markup—otherwise known as
semantic markup—can be understood by programs and other devices. Search engines, for
instance, can recognize a headline because it is wrapped in h1 tags and assign more importance
to it. Screen reader users can rely on headings as supplemental page navigation.

用semantic Markup不如用meaningful Markup容易被人,搜索引擎,或设备理解

Most importantly for the context of this book, meaningful markup provides you with a simple way
of targeting the elements you wish to style. It adds structure to a document and creates an
underlying framework to build upon. You can style elements directly without needing to add other
identifiers, and thus avoid unnecessary code bloat.

而且meaningful markup 容易定位

HTML includes a rich variety of meaningful elements (有意义的元素), such as
• h1, h2, and so on
• ul, ol, and dl

• strong and em
• blockquote and cite
• abbr, acronym, and code
• fieldset, legend, and label
• caption, thead, tbody, and tfoot

用Table还是用CSS布局总能引起大争论,现在明显胜负已分。

ID和Class名称

ID和Class名称, ID用于同一页面的唯一元素, Class可以用于同一页面的任意多个元素,类适合标识内容的类型或相似的条目

 

元素的ID和Class命名

一定要记住不要和表现有关而要和意义相关,说明元素是做什么用途而不是它看起来是什么,下面是一些例子

注意大小写要区分, 最好的方式是全部小写,如果有多个词,用连字符, 比如andy-budd

用ID还是Class

Class用于同一页面概念相似的元素, ID用于唯一元素

Div 和 Span

div 元素用来给文档增加结构,很多人误以为div没有语法意义。但是div其实代表division 并提供一个途径把文档分割成有意义的区间。

为了减少不必要的文档标记,只要在没有其他元素可以用时,采用div元素, 比如用 list 做一个main navigation ,没有必要把它包在div里面

<div class="nav">
<ul>
<li><a href="/home/">Home</a></li>
<li><a href="/about/">About Us</a></li>
<li><a href="/contact/">Contact</a></li>
</ul>
</div>
去除div,在 list里直接使用 class就好:
<ul class="nav">
<li><a href="/home/">Home</a></li>
<li><a href="/about/">About Us</a></li>
<li><a href="/contact/">Contact</a></li>
</ul>

Microformats

具体请参考 http://microformats.org  or google: Mircroformats:Empowering Your Mark-up for Web 2.0 by John Allsopp

不同版本的HTML和CSS

浏览器模式

standard 和quirks 模式,In standards mode, the browser renders a page according to the
specifications, and in quirks mode pages are displayed in a looser, more backward-compatible
fashion.

DocType 开关

The browser chooses which rendering method to use based on the existence of a DOCTYPE
declaration and the DTD being used. If an XHTML document contains a fully formed DOCTYPE,
it will normally be rendered in standards mode. For an HTML 4.01 document, a DOCTYPE
containing a strict DTD will usually cause the page to render in standards mode. A DOCTYPE
containing a transitional DTD and URI will also cause the page to render in standards mode,
while a transitional DTD without a URI will cause the page to render in quirks mode. A badly
formed or nonexistent DOCTYPE will cause both HTML and XHTML documents to be rendered
in quirks mode.

《CSS Mastery》 读书笔记 (1)的更多相关文章

  1. 【读书笔记】《Computer Organization and Design: The Hardware/Software Interface》(1)

    笔记前言: <Computer Organization and Design: The Hardware/Software Interface>,中文译名,<计算机组成与设计:硬件 ...

  2. 算法设计手冊(第2版)读书笔记, Springer - The Algorithm Design Manual, 2ed Steven S.Skiena 2008

    The Algorithm Design Manual, 2ed 跳转至: 导航. 搜索 Springer - The Algorithm Design Manual, 2ed Steven S.Sk ...

  3. [读书笔记]设计原本[The Design of Design]

    第1章 设计之命题 1.设计首先诞生于脑海里,再慢慢逐步成形(实现) 2.好的设计具有概念完整性:统一.经济.清晰.优雅.利落.漂亮... 第2章 工程师怎样进行设计思维——理性模型 1.有序模型的有 ...

  4. 《Unix编程艺术》读书笔记(1)

    <Unix编程艺术>读书笔记(1) 这两天開始阅读该书,以下是自己的体会,以及原文的摘录,尽管有些东西还无法全然吃透. 写优雅的代码来提高软件系统的透明性:(P134) Elegance ...

  5. 【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】

    [英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化. ...

  6. 【英语魔法俱乐部——读书笔记】 2 中级句型-复句&合句(Complex Sentences、Compound Sentences)

    [英语魔法俱乐部——读书笔记] 2 中级句型-复句&合句(Complex Sentences.Compound Sentences):(2.1)名词从句.(2.2)副词从句.(2.3)关系从句 ...

  7. Computer architecture Computer organization

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCEComputer architectureNINTH EDITION C ...

  8. 图解TCP/IP读书笔记(一)

    图解TCP/IP读书笔记(一) 第一章 网络基础知识 本学期的信安概论课程中有大量的网络知识,其中TCP/IP占了相当大的比重,让我对上学期没有好好学习计算机网络这门课程深感后悔.在老师的推荐下开始阅 ...

  9. 《Linux/Unix系统编程手册》读书笔记8 (文件I/O缓冲)

    <Linux/Unix系统编程手册>读书笔记 目录 第13章 这章主要将了关于文件I/O的缓冲. 系统I/O调用(即内核)和C语言标准库I/O函数(即stdio函数)在对磁盘进行操作的时候 ...

  10. 《Linux/Unix系统编程手册》读书笔记7 (/proc文件的简介和运用)

    <Linux/Unix系统编程手册>读书笔记 目录 第11章 这章主要讲了关于Linux和UNIX的系统资源的限制. 关于限制都存在一个最小值,这些最小值为<limits.h> ...

随机推荐

  1. uva 227 Puzzle (UVA - 227)

    感慨 这个题实在是一个大水题(虽然说是世界决赛真题),但是它给出的输入输出数据,标示着老子世界决赛真题虽然题目很水但是数据就能卡死你...一直pe pe直到今天上午AC...无比感慨...就是因为最后 ...

  2. Nodejs介绍及其安装

    一.Nodejs介绍 Nodejs英文网:https://nodejs.org/en/ Nodejs中文网:http://nodejs.cn/ Node.js 是一个基于 Chrome V8 引擎的 ...

  3. redis 和 memcached的区别

    redis和memcached的区别   Redis 和 Memcache 都是基于内存的数据存储系统.Memcached是高性能分布式内存缓存服务:Redis是一个开源的key-value存储系统. ...

  4. Git 基础教程 之 远程推送

    当你从远程仓库克隆时,实际上Git自动把本地的master分支和远程的master分支对应了起来,并且,远程仓库默认名称是origin. git remote 查看远程库信息 git remote - ...

  5. Spider-Python实战之通过Python爬虫爬取图片制作Win7跑车主题

    1. 前期准备 1.1 开发工具 Python 3.6 Pycharm Pro 2017.3.2 Text文本 1.2 Python库 requests re urllib 如果没有这些Python库 ...

  6. CSVHelper在Asp.Net MVC中的使用

    1,从数据库读取数据,然后导出CSV文件 [HttpPost] public FileResult ExportCSV() { var apps =....//linq以及EF从数据库查询数据 Mem ...

  7. 洛谷 P1491 集合位置

    P1491 集合位置 题目描述 每次有大的活动,大家都要在一起“聚一聚”,不管是去好乐迪,还是避风塘,或者汤姆熊,大家都要玩的痛快.还记得心语和花儿在跳舞机上的激情与释放,还记得草草的投篮技艺是如此的 ...

  8. 使用Java VisualVM配置Java应用程序/分析CPU或内存的使用情况(转)

    以下内容翻译自(机翻):https://baptiste-wicht.com/posts/2010/07/profile-applications-java-visualvm.html 当您需要发现应 ...

  9. firedac的数据序列和还原单元(Data.FireDACJSONReflect.pas)之拷贝FIREDAC数据集

    使用流做中转 procedure CopyDataSet(const ASource, ADest: TFDAdaptedDataSet);var LStream: TStream;begin LSt ...

  10. (转)linux口令相关文件(/etc/passwd和/etc/shadow)

    在linux中,口令文件在/etc/passwd中,早期的这个文件直接存放加密后的password,前两位是"盐"值,是一个随机数.后面跟的是加密的password.为了安全,如今 ...