• HTML定义

 

html字面的意思hyper text mark-up language,超-文本-标记-语言

 

为什么叫超,是相对于线型而言的,早期的计算机只能执行一条指令,到下一条指令,而html可以任意的跳转,比如从baidu.com自由的跳到google.com

 

这里需要指出html是存在规范的,通常指的html是符合html4.01规范的http://www.w3.org/TR/1999/REC-html401-19991224/

这是由w3c(world wide web consortium http://www.w3.org/Consortium/)建立并推荐的

w3c    Tim Berners-Lee创建的,负责开发Web标准,目标是发挥互联网的全部潜能。

 

  • 元素和标签
    • 元素是用户结构化html  <span>ell</span>这是个完整的元素
  • html标签是对大小写不敏感的,就是说写'hTml '' HTML'是浏览器都可以识别的,但在xhtml严格文档模式下(以<!doctype xxxx>开头),需要小写。小写是好的实践

 

  • <br /> 起始标签和结束标签写一起了

 

 

html4.01规范指出,编程的时候应该注意:

1.结构和展现分离

2.考虑通用的accessability,考虑盲人,语音读者。。

3.table的使用上按规范走,提升浏览器的渲染速度

 

 Attribute/value pairs appear before the final ">" of an element's start tag.

属性的价值对出现在开始标签内

We recommend using quotation marks even when it is possible to eliminate them

属性值应该用引号包着

 

所有的属性列表

http://www.w3.org/TR/1999/REC-html401-19991224/index/attributes.html

所有的元素列表

http://www.w3.org/TR/1999/REC-html401-19991224/index/elements.html

 

字符索引:

  • "&lt;" represents the < sign.
  • "&gt;" represents the > sign.
  • "&quot;" represents the " mark.
  • "&#229;" (in decimal) represents the letter "a" with a small circle above it.
  • "&#1048;" (in decimal) represents the Cyrillic capital letter "I".
  • "&#x6C34;" (in hexadecimal) represents the Chinese character for water.

 

源文档 <http://www.w3.org/TR/1999/REC-html401-19991224/intro/sgmltut.html#character-entities>

 

注释:

<!-- this is a comment -->
<!-- and so is this one,
    which occupies more than one line -->

 

常犯的错误是将 ---连续三个中杠写到注释中(试验了一下,在iechrome下都没有问题,能正确注释。。)

 

http://www.w3.org/TR/1999/REC-html401-19991224/sgml/dtd.html

最令人头疼的DTD,文档类型定义。从来没有记住过

如何读dtdhttp://www.w3.org/TR/1999/REC-html401-19991224/intro/sgmltut.html#howtodtd

<!ELEMENT A - - (%inline;)* -(A)>

a不能nest a自身,默认为inline元素

 

过了一遍DTD,不允许有结束标签的有:

BRAREALINKIMGPARAMHRINPUTCOLBASEMETA

 

HTML文档以二进制流的形式在网路中传播,contentType"text/html"代表html文档

charset的可选属性被建议加上

 

The "charset" parameter identifies a character encoding, which is a method of converting a sequence of bytes into a sequence of characters. This conversion fits naturally with the scheme of Web activity: servers send HTML documents to user agents as a stream of bytes; user agents interpret them as a sequence of characters. The conversion method can range from simple one-to-one correspondence to complex switching schemes or algorithms.

charset定义了一个字符的编码,就是定义其如何从二进制流转化成字符。web的机制:服务器向user agent传递html文档,以二进制流的方式,user agent将他们解析为字符串,至于如何解析,由charset决定