zoukankan      html  css  js  c++  java
  • 小强的HTML5移动开发之路(13)——HTML5中的全局属性

    来自:http://blog.csdn.net/dawanganban/article/details/18179483

    一、accssskey  快捷键

    1. <!DOCTYPE HTML>  
    2. <html>  
    3. <body>  
    4.   
    5. <a href="http://blog.csdn.net/column/details/dawanganban-html5.html" accesskey="w">小强的HTML5移动开发之路</a><br />  
    6. <a href="http://blog.csdn.net/column/details/android-growup.html" accesskey="g">Android菜鸟的成长笔记</a>  
    7.   
    8. <p><b>注释:</b>请使用 Alt + <i>accessKey</i> 来访问带有快捷键的元素。</p>  
    9.   
    10. </body>  
    11. </html>  

    有兴趣的朋友可以按住Alt + g 和 Alt + w试一下

    小强的HTML5移动开发之路
    Android菜鸟的成长笔记

    注释:请使用 Alt + accessKey 来访问带有快捷键的元素。

    该标签在HTML4和HTML5之间没有差异。

    二、class 属性,规定元素类名

    1. <!DOCTYPE HTML>  
    2. <html>  
    3. <head>  
    4. <style type="text/css">  
    5. h1.intro {color:blue;}  
    6. p.important {color:green;}  
    7. </style>  
    8. </head>  
    9. <body>  
    10.   
    11. <h1 class="intro">Header 1</h1>  
    12. <p>A paragraph.</p>  
    13. <p class="important">请注意这个重要的段落。:)</p>  
    14.   
    15. </body>  
    16. </html>  

    三、contenteditable 属性规定是否可编辑元素的内容

    1. <!DOCTYPE HTML>  
    2. <html>  
    3. <body>  
    4.   
    5. <p contenteditable="true">这是一段可编辑的段落。请试着编辑该文本。</p>  
    6.   
    7. </body>  
    8. </html>  

    这是一段可编辑的段落。请试着编辑该文本。

    contenteditable 属性是 HTML5 中的新属性

    四、contextmenu 属性为元素规定上下文菜单。这个菜单会在用户右键点击元素时出现

    目前没有任何主流浏览器支持 contextmenu 属性。

    1. <!DOCTYPE html>  
    2. <html>  
    3. <body>  
    4.   
    5. <p contextmenu="supermenu">本段落拥有一个名为 "supermenu" 的上下文菜单。这个菜单会在用户右键单击该段落时出现。</p>    
    6.   
    7. <menu id="supermenu">  
    8.   <command label="Step 1: Write Tutorial" onclick="doSomething()">  
    9.   <command label="Step 2: Edit Tutorial" onclick="doSomethingElse()">  
    10. </menu>  
    11.   
    12. <p><b>注释:</b>目前的主流浏览器都不支持 contextmenu 属性。</p>  
    13.   
    14. </body>  
    15. </html  
    五、dir 属性规定元素内容的文本方向。

    1. <p dir="rtl">Write this text right-to-left!</p>  

    描述
    ltr从左向右的文本方向。
    rtl从右向左的文本方向。
    auto让浏览器根据内容来判断文本方向。仅在文本方向未知时推荐使用。
    六、draggable 属性规定元素是否可拖动。
    描述
    true规定元素是可拖动的。
    false规定元素是不可拖动的。
    auto使用浏览器的默认特性。

    目前只有 Firefox、Chrome 以及 Safari 支持 draggable 属性。

    七、dropzone 属性规定当被拖动的数据在拖放到元素上时,是否被复制、移动或链接。

    目前没有任何主流浏览器支持 dropzone 属性。

    八、hidden 属性规定对元素进行隐藏。

    hidden 属性是 HTML5 中的新属性。

    九、id 属性规定 HTML 元素的唯一的 id

    1. <html>  
    2. <head>  
    3. <script type="text/javascript">  
    4. function change_header()  
    5. {  
    6. document.getElementById("myHeader").innerHTML="Nice day!";  
    7. }  
    8. </script>  
    9. </head>  
    10.   
    11. <body>  
    12. <h1 id="myHeader">Hello World!</h1>  
    13. <button onclick="change_header()">改变文本</button>  
    14. </body>  
    15.   
    16. </html>  

    十、lang 属性规定元素内容的语言。

    ISO 639-1 为各种语言定义了缩略词。您可以在 HTML 和 XHTML 中的 lang 和 xml:lang 属性中使用它们。

    LanguageISO Code
    Abkhazianab
    Afaraa
    Afrikaansaf
    Albaniansq
    Amharicam
    Arabicar
    Armenianhy
    Assameseas
    Aymaraay
    Azerbaijaniaz
    Bashkirba
    Basqueeu
    Bengali (Bangla)bn
    Bhutanidz
    Biharibh
    Bislamabi
    Bretonbr
    Bulgarianbg
    Burmesemy
    Byelorussian (Belarusian)be
    Cambodiankm
    Catalanca
    Cherokee 
    Chewa 
    Chinese (Simplified)zh
    Chinese (Traditional)zh
    Corsicanco
    Croatianhr
    Czechcs
    Danishda
    Divehi 
    Dutchnl
    Edo 
    Englishen
    Esperantoeo
    Estonianet
    Faeroesefo
    Farsifa
    Fijifj
    Finnishfi
    Flemish 
    Frenchfr
    Frisianfy
    Fulfulde 
    Galiciangl
    Gaelic (Scottish)gd
    Gaelic (Manx)gv
    Georgianka
    Germande
    Greekel
    Greenlandickl
    Guaranign
    Gujaratigu
    Hausaha
    Hawaiian 
    Hebrewhe, iw
    Hindihi
    Hungarianhu
    Ibibio 
    Icelandicis
    Igbo 
    Indonesianid, in
    Interlinguaia
    Interlingueie
    Inuktitutiu
    Inupiakik
    Irishga
    Italianit
    Japaneseja
    Javanesejv
    Kannadakn
    Kanuri 
    Kashmiriks
    Kazakhkk
    Kinyarwanda (Ruanda)rw
    Kirghizky
    Kirundi (Rundi)rn
    Konkani 
    Koreanko
    Kurdishku
    Laothianlo
    Latinla
    Latvian (Lettish)lv
    Limburgish ( Limburger)li
    Lingalaln
    Lithuanianlt
    Macedonianmk
    Malagasymg
    Malayms
    Malayalamml
      
    Maltesemt
    Maorimi
    Marathimr
    Moldavianmo
    Mongolianmn
    Nauruna
    Nepaline
    Norwegianno
    Occitanoc
    Oriyaor
    Oromo (Afan, Galla)om
    Papiamentu 
    Pashto (Pushto)ps
    Polishpl
    Portuguesept
    Punjabipa
    Quechuaqu
    Rhaeto-Romancerm
    Romanianro
    Russianru
    Sami (Lappish) 
    Samoansm
    Sangrosg
    Sanskritsa
    Serbiansr
    Serbo-Croatiansh
    Sesothost
    Setswanatn
    Shonasn
    Sindhisd
    Sinhalesesi
    Siswatiss
    Slovaksk
    Sloveniansl
    Somaliso
    Spanishes
    Sundanesesu
    Swahili (Kiswahili)sw
    Swedishsv
    Syriac 
    Tagalogtl
    Tajiktg
    Tamazight 
    Tamilta
    Tatartt
    Telugute
    Thaith
    Tibetanbo
    Tigrinyati
    Tongato
    Tsongats
    Turkishtr
    Turkmentk
    Twitw
    Uighurug
    Ukrainianuk
    Urduur
    Uzbekuz
    Venda 
    Vietnamesevi
    Volapukvo
    Welshcy
    Wolofwo
    Xhosaxh
    Yi 
    Yiddishyi, ji
    Yorubayo
    Zuluzu

    十一、spellcheck 属性规定是否对元素内容进行拼写检查。

    可对以下文本进行拼写检查:

      • 类型为 text 的 input 元素中的值(非密码)
      • textarea 元素中的值
      • 可编辑元素中的值

    spellcheck 属性是 HTML5 中的新属性。

    十二、style 属性规定元素的行内样式(inline style)HTML4和HTML5无差异
    十三、tabindex 属性规定当使用 "tab" 键进行导航时元素的顺序。

    1. <!DOCTYPE HTML>  
    2. <html>  
    3. <body>  
    4.   
    5. <a href="http://www.w3school.com.cn/" tabindex="2">W3School</a><br />  
    6. <a href="http://www.google.com/" tabindex="1">Google</a><br />  
    7. <a href="http://www.microsoft.com/" tabindex="3">Microsoft</a>  
    8.   
    9. </body>  
    10. </html>  

    十四、title   属性规定关于元素的额外信息

    1. <!DOCTYPE HTML>  
    2. <html>  
    3. <body>  
    4.   
    5. <p><abbr title="世界卫生组织">WHO</abbr> 成立于 1948。</p>  
    6. <p title="免费的 Web 教程">W3School.com.cn</pl>  
    7.   
    8. </body>  
    9. </html>  

  • 相关阅读:
    Django在新浪SAE中使用storage服务实现文件上传保存
    安装mysql5.1.30时mysql_install_db出现FATAL ERROR: Could not find mysqld错误解决
    Ubuntu下的负载均衡Web集群配置
    ERROR 2002 (HY000): Can't connect to local MySQL server through so...
    Ubuntu下的C/C++环境搭建
    php linux sphinx 安装
    sphinx安装步骤
    Ubuntu下vmwaretools安装
    LAMP全新安装 Linux+Apache+MySQL+PHP+phpMyadmin+Zend
    ubuntu 彻底删除MySQL数据库实操
  • 原文地址:https://www.cnblogs.com/wanghang/p/6298968.html
Copyright © 2011-2022 走看看