Web標準是由一系列標準組合而成。一個網頁主要由三部分組成:結構層、表現層和行爲層。javascript
對應的標準也分三方面:css
結構化標準語言,就是W3C規定的主要包括HTML和XHTML以及XML,在頁面body裏面咱們寫入的標籤都是爲了頁面的結構。html
表現標準語言主要包括CSS(Cascading Style Sheets)層疊式樣式表,經過CSS樣式表,W3C建立CSS標準的目的是以CSS取代HTML表格式佈局、幀和其餘表現的語言,經過CSS樣式能夠是頁面的結構標籤更具美感。前端
行爲是指頁面和用戶具備必定的交互,同時頁面結構或者表現發生變化,標準主要包括對象模型(如W3C DOM)、ECMAScript並要求這三部分分離。html5
DOM是Document Object Model文檔對象模型的縮寫。DOM解決了Netscaped的Javascript和Microsoft的Jscript之間的衝突,給予web設計師和開發者一個標準的方法,讓他們來訪問他們站點中的數據、腳本和表現層對像。java
ECMAScript是ECMA(EuropeanComputer Manufacturers Association)制定的標準腳本語言(JAVAScript)jquery
W3C對web標準提出了規範化的要求,也就是在實際編程中的一些代碼規範。程序員
主要包含以下幾點:web
[!NOTE]
語義化就是是讓機器能夠讀懂內容,web頁面的解析是由搜索引擎來進行搜索,機器來解析。ajax
h1~h六、thead、ul、ol等標籤,初期的語義化標籤:程序員利用HTML標籤的id和class屬性,進一步對HTML標籤進行描述,如對頁腳HTML標籤添加如id="footer"或者class="footer"的屬性(值)(使用有語義的對於須要聲明的變量和class,id)
w3C採用了header/footer; section(章節、頁眉、頁腳)/article(內容區域); nav導航;aside 不重要的內容;em(emphasize)/strong加強; i(icon)製做圖標
[!NOTE]
關鍵點:HTML是一種基本的WEB網頁設計語言,XHTML是一個基於XML的置標語言
[!NOTE]
行內元素:a、b、span、img、input、strong、select、label、em、button、textarea
塊級元素:div、ul、li、dl、dt、dd、p、h1-h六、blockquote
空元素:br、meta、hr、link、input、img
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>login test</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="login test"> </head> <body> <div id="form-div"> <form id="form1" action="/users/login" method="post"> <p>用戶名:<input name="userName" type="text" id="txtUserName" tabindex="1" size="15" value=""/></p> <p>密 碼:<input name="password" type="password" id="TextBox2" tabindex="2" size="16" value=""/></p> <p><input type="submit" value="登陸"> <input type="reset" value="重置"></p> </form> </div> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>login test</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="ajax方式"> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> function login() { $.ajax({ //幾個參數須要注意一下 type: "POST",//方法類型 dataType: "json",//預期服務器返回的數據類型 url: "/users/login" ,//url data: $('#form1').serialize(), success: function (result) { console.log(result);//打印服務端返回的數據(調試用) if (result.resultCode == 200) { alert("SUCCESS"); } ; }, error : function() { alert("異常!"); } }); } </script> </head> <body> <div id="form-div"> <form id="form1" onsubmit="return false" action="##" method="post"> <p>用戶名:<input name="userName" type="text" id="txtUserName" tabindex="1" size="15" value=""/></p> <p>密 碼:<input name="password" type="password" id="TextBox2" tabindex="2" size="16" value=""/></p> <p><input type="button" value="登陸" onclick="login()"> <input type="reset" value="重置"></p> </form> </div> </body> </html>
[!NOTE]
擴展思考:Form表單提交數據給一個非同源的網址,如在A網址(http://www.A.com)上直接向B網站(http://www.B.com)發送數據請求, 爲何不會觸發瀏覽器的同源策略限制呢?