html5
- html In a nutshell
The<head>
element contains meta information about the document
The<body>
element contains the visible page content
HTML elements are the building blocks of HTML pages
HTML elements are represented by tags
HTML tags label pieces of content such as “heading”, “paragraph”, “table”, and so on
tags:
<tagname>content goes here...</tagname>
html basic
-
Headings
e.g.,<h1>
-
Paragraphs
<p>
-
Links
<a>
<a href="https://www.w3schools.com">This is a link</a>
- local links
<a href="html_images.asp">HTML Images</a>
- colors
By default, a link will appear like this (in all browsers):
An unvisited link is underlined and blue
A visited link is underlined and purple
An active link is underlined and red
You can change the default colors, e.g.:
123456789101112131415161718192021a:link {color: green;background-color: transparent;text-decoration: none;}a:visited {color: pink;background-color: transparent;text-decoration: none;}a:hover {color: red;background-color: transparent;text-decoration: underline;}a:active {color: yellow;background-color: transparent;text-decoration: underline;}</style>- target Attribute
Available values:_blank
,_self
,_parent
,_top
,framename - Opens the linked document in a named frame
- images
Note:border:0
; is added to prevent IE9 (and earlier) from displaying a border around the image (when the image is a link). - Create a Bookmark
12<h2 id="C4">Chapter 4</h2><a href="#C4">Jump to Chapter 4</a> - local links
-
Images
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
The style attributes are valid in HTML5 and suggested.- Floating
let the image float to the right or to the left of a text - maps
An image-map is an image with clickable areas. - Background image
123<body style="background-image:url('clouds.jpg')"><h2>Background Image</h2></body>- picture element
Introduced since html5.
Always specify an element as the last child element of the
- Floating
-
Buttons
<button>Click me</button>
-
Lists
HTML lists are defined with the<ul>
(unordered/bullet list) or the<ol>
(ordered/numbered list) tag, followed by<li>
tags (list items)
<ul>
<li>Coffee</li>
</ul>
elements
An HTML element usually consists of a start tag and end tag, with the content inserted in between:
<tagname>Content goes here...</tagname>
-
<br>
element
which indicates a line break.
Empty elements can be “closed” in the opening tag like this:<br />
.
HTML5 does not require empty elements to be closed. But if you want stricter validation, or if you need to make your document readable by XML parsers, you must close all HTML elements properly. -
<hr>
水平分割线
a thematic break. -
headings
Note: Use HTML headings for headings only. Don’t use headings to make text BIG or bold.
For Bigger Headings use:<h1 style="font-size:60px;">Heading 1</h1>
-
element has nothing to do with HTML headings.<head>
Element
The HTML
The element is a container for metadata. HTML metadata is data about the HTML document. Metadata is not displayed.
The element is placed between the tag and the tag: -
<pre>
The text inside aelement is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks. link
-
Formating element
12345678910<b> - Bold text<strong> - Important text<i> - Italic text<em> - Emphasized text<mark> - Marked text<small> - Small text<del> - Deleted text<ins> - Inserted text<sub> - Subscript text<sup> - Superscript textNote: Browsers display
<strong
> as<b
>, and<em
> as<i
>. However, there is a difference in the meaning of these tags:<b
> and<i
> defines bold and italic text, but<strong
> and<em
> means that the text is “important”. -
Quotations
<q>
for short and<blockquote>
for long Quotations
e.g., :
|
|
<abbr>
Marking abbreviations can give useful information to browsers, translation systems and search-engines.<cite>
The HTML element defines the title of a work.<bdo>
Bi-Directional Override
e.g.,<bdo dir="rtl">
comments
e.g., <!-- Do not display this at the moment <img border="0" src="pic_mountain.jpg" alt="Mountain"> -->
Attributes
Attributes usually come in name/value pairs like: name=“value”, blank is used to sperate attributes.
e.g., <a href="https://www.w3schools.com">This is a link</a>
href
is an attributes.
src
width
&height
alt
The alt attribute specifies an alternative text to be used, when an image cannot be displayed.
The value of the attribute can be read by screen readers. This way, someone “listening” to the webpage, e.g. a blind person, can “hear” the element.style
color, font, size etc.
e.g.,<p style="color:red">I am a paragraph</p>
lang
<html lang="en-US">
is important for accessibility applications (screen readers) and search engines.title
Here, a title attribute is added to theelement. The value of the title attribute will be displayed as a tooltip when you mouse over the paragraph. HTML Attributes
JSON[1]
JSON[1] 结构有两种结构[2]
json简单说就是javascript中的对象和数组,所以这两种结构就是对象和数组两种结构,通过这两种结构可以表示各种复杂的结构
1、对象:对象在js中表示为“{}”括起来的内容,数据结构为 {key:value,key:value,…}的键值对的结构,在面向对象的语言中,key为对象的属性,value为对应的属性值,所以很容易理解,取值方法为 对象.key 获取属性值,这个属性值的类型可以是 数字、字符串、数组、对象几种。
2、数组:数组在js中是中括号“[]”括起来的内容,数据结构为 [“java”,“javascript”,“vb”,…],取值方式和所有语言中一样,使用索引获取,字段值的类型可以是 数字、字符串、数组、对象几种。
经过对象、数组2种结构就可以组合成复杂的数据结构了。
Forms
-
<input>
Element- type value
text
,radio
,submit
name
Attribute
Each input field must have a name attribute to be submitted. If the name attribute is omitted, the data of that input field will not be sent at all.
- type value
-
Action Attribute
The action attribute defines the action to be performed when the form is submitted. -
Target Attribute
- type value
_self
,_blank
,
- type value
TIPS
- .htm or .html has no difference.
- HTML tags are not case sensitive
The HTML5 standard does not require lowercase tags, but W3C recommends lowercase in HTML, and demands lowercase for stricter document types like XHTML. - Quote Attribute Values
W3C recommends quotes in HTML, and demands quotes for stricter document types like XHTML.
single quotes can also be used. - With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code.
- display special symbols
© -©
® -®
™ -™
- MIME type
也称作content type。Content-Type: text/HTML
:http协议中Content-Type
的值就是mime type。
更多信息见:wiki 互联网媒体类型
CSS3
CSS(层叠样式表 Cascading Style Sheets),专门用来负责html里的<style>
。
CSS的语法很简单,选择器:{属性1:属性值; 属性2:属性值}。
CSS can be added to HTML elements in 3 ways:
- Inline - by using the style attribute in HTML elements
- Internal - by using a
<style>
element in the<head>
section - External - by using an external CSS file
Three examples:
|
|
Your first test:[2]
|
|
- id attribute
Note: The id of an element should be unique within a page, so the id selector is used to select one unique element!
|
|
- class attribute
|
|
CSS properties
border【Note: border must have at last 3 properites】; color; font-size; font-family; padding & margin(inside/outside the border);
JavaScript
<noscript>
Defines an alternate content for users that do not support client-side scripts.- Examples
|
|
Chares
-
port
80: http
443: https -
浏览器的解析方式[3]
浏览器解析html页面首先浏览器先下载html,然后在内存中把html代码转化成Dom Tree,然后浏览器根据Dom Tree上的Node分析css和Images,当文档下载遇到js时,js独立下载。
-
HMAC
HMAC是密钥相关的哈希运算消息认证码,HMAC运算利用哈希算法,以一个密钥和一个消息为输入,生成一个消息摘要作为输出。
hmac主要应用在身份验证中,它的使用方法是这样的:
(1) 客户端发出登录请求(假设是浏览器的GET请求)
(2) 服务器返回一个随机值,并在会话中记录这个随机值
(3) 客户端将该随机值作为密钥,用户密码进行hmac运算,然后提交给服务器
(4) 服务器读取用户数据库中的用户密码和步骤2中发送的随机值做与客户端一样的hmac运算,然后与用户发送的结果比较,如果结果一致则验证用户合法 -
REST/RESTful
参考:理解RESTful架构
Representational State Transfer,“表现层状态转化”,主语应该是resource。RESTful架构:
(1)每一个URI(统一资源定位符)代表一种资源;
(2)客户端和服务器之间,传递这种资源的某种表现层;
(3)客户端通过四个HTTP动词,对服务器端资源进行操作,实现"表现层状态转化"。
-
协程
优点:- 最大的优势就是协程极高的执行效率。因为子程序切换不是线程切换,而是由程序自身控制,因此,没有线程切换的开销,和多线程比,线程数量越多,协程的性能优势就越明显。
- 第二大优势就是不需要多线程的锁机制,因为只有一个线程,也不存在同时写变量冲突,在协程中控制共享资源不加锁,只需要判断状态就好了,所以执行效率比多线程高很多。
-
socket
- introduction
默认端口也是80和443;
协议标识符是ws(如果加密,则为wss); - socket所在的层次以及它是什么:简单理解Socket
从字面意思来看TCP/IP是TCP和IP协议的合称,但实际上TCP/IP协议是指因特网整个TCP/IP协议族。不同于ISO模型的七个分层,TCP/IP协议参考模型把所有的TCP/IP系列协议归类到四个抽象层中
应用层:TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet 等等
传输层:TCP,UDP
网络层:IP,ICMP,OSPF,EIGRP,IGMP
数据链路层:SLIP,CSLIP,PPP,MTU
我们知道两个进程如果需要进行通讯最基本的一个前提能能够唯一的标示一个进程,在本地进程通讯中我们可以使用PID来唯一标示一个进程,但PID只在本地唯一,网络中的两个进程PID冲突几率很大,这时候我们需要另辟它径了,我们知道IP层的ip地址可以唯一标示主机,而TCP层协议和端口号可以唯一标示主机的一个进程,这样我们可以利用ip地址+协议+端口号唯一标示网络中的一个进程。
- introduction
简单来说,你浏览的网页(网址以HTTP://开头)都是HTTP协议传输到你的浏览器的,而HTTP是基于socket之上的。socket是一套完成TCP.UDP协议的接口.
HTTP协议:简单对象访问协议,对应于应用层,HTTP协议是基于TCP连接的。
TCP协议:对应于传输层
IP协议:对应于网络层
TCP/IP是传输层协议,主要解决数据如果在网络中传输;
而HTTP协议是应用层协议,主要解决如何包装数据。
socket是对TCP/IP协议的封装,socket本身并不是协议,而是一个调用接口(API),通过socket我们才能使用TCP/IP协议.
http连接:http连接就是所谓的短连接,即客户端向服务器端发送一次请求,服务器端响应后连接即会断掉.
socket连接:socket连接就是所谓的长连接,理论上客户端和服务器端一旦连接其连接将不会主动断掉;但是由于各种环境因素可能会连接断开,比如说:服务器端或客户端主机down了,网络故障,或者两者之间长时间没有传输数据,网络防火墙可能会断开该连接以释放网络资源。所以当一个socket连接中没有数据传输的时候,那么为了维持连接需要发送心跳消息,具体心跳消息格式是开发者自己定义的。