Table of Contents
tag
Semantictag" >UpdateSemantictag
Why there are semantic tags
Application tag
list(data list)]" >[datalist(data list)]
Progress bar)]" >[progress (Progress bar)]
[meter (numeric display)]
[menu (right-click menu)]
[details]
Link relationship description: used to describe the relationship between the specified link and the current document, to facilitate the machine to understand the document structure
Structured data tag
ARIA
Custom attribute data
" >Video
<video src="fun.mp4" controls="controls"></video>
Copy after login
" >
<video src="fun.mp4" controls="controls"></video>
Copy after login
Home Web Front-end H5 Tutorial Notes organized by h5

Notes organized by h5

Apr 11, 2017 pm 02:38 PM

tag

UpdateSemantictag

    header标签
    nav标签
    section标签
    article标签
    aside标签
    widget标签
    footer标签
Copy after login

Why there are semantic tags

能够便于开发者阅读和写出更优雅的代码,代码如诗
同时让浏览器或是网络爬虫可以很好地解析,从而更好分析其中的内容
更好地搜索引擎优化

切记:HTML的职责是描述一块内容是什么(或其意义)而不是它长的什么样子,它的外观应该由CSS来决定。
Copy after login

Application tag

[datalist(data list)]

datalist The presentation of the data list requires a carrier

            <input type="text" list="input_list">
            <datalist id="datalist">
                <option value="选项框1"></option>
                <option value="选项框2"></option>
            </datalist>

            <input type="text" list="input_list">
            <datalist id="datalist">
                <option value="选项框1"></option>
                <option value="选项框2"></option>
            </datalist>
Copy after login

[progress (Progress bar)]

To change its style, you need to first change -webkit- appearanceSet to none

            <style>
                .my_progress{
                    -webkit-appearance:none;
                }
                .my-progress::-webkit-progress-bar{
                    //样式
                }
            </style>
            <progress class="my_progress" value="10" max="100"></progress>
Copy after login

[meter (numeric display)]

Very few browsers support

            <meter min="0" max="100" low="40" hign="90" optimun="100" value="91"></meter>
Copy after login

The maximum and minimum values ​​of the display: max, min
The maximum and minimum values ​​that the display can reach: high, low
The best value of the measurement range of the display: optimal
The current value displayed by the display: value

Firefox compatible

[details]

Click on a content to expand the panel, compatible with Firefox and Google

Properties

Common link relationship table

    alternate       文档的可选版本(例如打印页、翻译页或镜像)
    stylesheet      文档的外部样式表
    start           集合中的第一个文档
    next            集合中的下一个文档
    prev            集合中的前一个文档
    contents        文档目录
    index           文档索引
    glossary        文档中所用字词的术语表或解释
    copyright       包含版权信息的文档
    chapter         文档的章
    section         文档的节
    subsection      文档的子段
    appendix        文档附录
    help            帮助文档
    bookmark        相关文档
    nofollow        用于指定 Google 搜索引擎不要跟踪链接
    licence         一般用于文献,表示许可证的含义
    tag             标签集合
    friend          友情链接


    案例

    <link rel="prev" href="#">
    <link rel="next" href="#">
    <a rel="prev" href="#">上一页</a>
    <a rel="next" href="#">下一页</a>

    <link rel="stylesheet" href="style.css">
    <link rel="alternate" type="application/rss+xml" href="http://myblog.com/feed">
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="pingback" href="http://myblog.com/xmlrpc.php">
    <link rel="prefetch" href="http://myblog.com/main.php">

    <a rel="archives" href="http://myblog.com/archives">old posts</a>
    <a rel="external" href="http://notmysite.com">tutorial</a>
    <a rel="license" href="http://www.apache.org/licenses/LICENSE-2.0">license</a>
    <a rel="nofollow" href="http://notmysite.com/sample">wannabe</a>
    <a rel="tag" href="http://myblog.com/category/games">games posts</a>
Copy after login

Structured data tag

Advanced stuff, currently only supported by Google
is to make it easy to crawl the data on the webpage

<p itemscope itemtype="http://example.com/hello">
      <p>我叫
        <span itemprop="主人">汪磊</span>。
      </p>
      <p>我养了一条叫
        <span itemprop="狗名">旺财</span>的
        <span itemprop="品种">金毛</span>犬。
      </p>
</p>

        比如抓取出:
        主人:汪磊
        狗名:旺财
        品种:金毛
Copy after login

ARIA

####Accessible Rich Internet Application (无障碍富互联网应用程序)
    主要针对于屏幕阅读设备(e.g. NVDA),更快更好地理解网页
    不仅仅是为了盲人用户,更多语义化
1.数据注解,类似lable,只不过label是针对表格
2.可以通过aria知道数据的强相关

aria由一套属性组成,属性分为role以及对应的states和properties,
aria将html元素分为六种role,每种有对应的states和properties,
但有一些是共用的,比如

        aria-atomic
        aria-busy(state)
        aria-describedby
        aria-disabled(state)
        aria-dropeffect
        aria-flowto
        aria-haspopup
        aria-hidden(state)
        aria-invalid(state)
        aria-label
        aria-labelledby
        aria-owns
        aria-relevant

        举个伪元素例子,

        <p role="radio" aria-checked="true" aria-label="单选2" tabindex="0">单选tabindex="0"</p>

        这个p模拟了radio的功能,在平时读屏软件是分辨不出来的,
        但是加上role及aria-checked状态,
        在读屏软件(NVDA)中读出来就是:

单选2 单选按钮 选中 第1页 共1项
Copy after login

For detailed attributes, see: ARIA Tenpay Design Center.html

Custom attribute data

通过DOM存储与DOM对象强相关的数据

1.可以给html里的所有dom对象都可以添加一些data-xxx的属性
2.用来记录与当前DOM强相关的数据

<ul id="users">
  <li data-id="1" data-age="18" data-gender="true">张三</li>
  <li data-id="2" data-age="18" data-gender="false">李四</li>
  <li data-id="3" data-age="18" data-gender="true">王二</li>
</ul>
Copy after login

Case 1:





    ##

            <script>
            //键是ID 值是信息
                var data = {
                    01:{
                        name:"伟哥哥",
                        age:"18"
                    },
                    02:{
                        name:"伟哥哥",
                        age:"19"
                    },
                    03:{
                        name:"伟哥哥",
                        age:"20"
                    }
    
                    //jQuery操作一定要做变量本地化
                    var list = document.getElementById("list");
                    for(var id in data){
                        var item = data[id];
                        var liElement = document.createElement("li");
                        //liElement.innerHTML = item.name;
                        liElement.appendChild(document.createTextNode(item.name));
                        liElement.setAttribute("data-age",item.age);
                        liElement.setAttribute("data-id",item.id);
                        list.appendChild(liElement);//变量本地化
    
                        //此处才将元素加到界面上
                        liElement.addEventListener("click",function(){
                            //alert(this.name);
                            //this 是当前点击的元素
                            //alert(this.getAttribute("data-age"));
                            console.log(this.dataset["age"]);
                        })
                    }
    
                };
            </script>
    Copy after login
    Case 2:

            <body>
                <ul id="users">
                    <li class="item" data-id="1" data-age="18" data-gender="true">
                        张三
                        <pre class="brush:php;toolbar:false">
                                     
  •                   李四                     
    
                    
  •                 
  •                   王二                   
    
                    
  •                               <script>             var ul = document.getElementById('users');             for (var i = 0; i < ul.children.length; i++) {                 var li = ul.children[i];                 // JS 添加data属性                 i.setAttribute('data-name', li.innerText);                 i.children[0].innerText = '';                 or (var key in li.dataset) {                     li.children[0].innerText += key + ':' + li.dataset[key] + '\n';                 }             }         </script>
    Copy after login
    Case 3:

                <body>
                    <p class="tabs">
                        <ul>
                            <li data-target=".panel-new">新闻</li>
                            <li data-target=".panel-bagua">八卦</li>
                            <li data-target=".panel-sport">体育</li>
                        </ul>
                        <p class="panel-new"></p>
                        <p class="panel-bagua"></p>
                        <p class="panel-sport"></p>
                    </p>
                    <script>
                    $(function(){
                        //写这个是为了有一个单独作用于,避免污染
                        //api是应用程序编程接口
                        var $lis = $('.tabs>ul>li');
                        $lis.on("click",function(){
                        //获取目标对象的选择器
                        var targetSelector = $(this).data('target');
                        var $target = $(targetSelector);
                        });
                    });
                    </script>
                </body>
    Copy after login
    Smart form

    New form type

        <form action="#">
            //repuired表示必须的,表示填写框不能为空,会有提示但是提示不能更改
            <label>text:<input type="text" required></label></br>
    
            //只能判断中间是否有@
            <label>email:<input type="email" value="ice@wedn.net"></label><br>
            <label>date:<input type="date" min="2014-10-14" max="2020-10-14" value="2016-08-14"></label><br>
    
            //拖动条,可以获得拉到的地方的数字
            <label>range:<input type="range" min="0" max="50" value="10"></label> <br>
            <label>search:<input type="search" results="10" placeholder="搜点啥?"></label><br>
            <label>tel:<input type="tel" placeholder="(010) 888-888" pattern="^\(?\d{3}\)?[-\s]\d{3}[-\s]\d{4}.*?$"></label><br>
            <label>color:<input type="color" placeholder="e.g. #bbbbbb"></label><br>
            <label>number:<input type="number" step="1" min="-5" max="10" value="0"></label><br>
            <input type="submit" value="提交">
        </form>
    Copy after login

    Virtual keyboard adaptation

            手机键盘会根据不同的type类型弹出不同键盘类型
            如打开数字键盘,密码键盘,邮件键盘
            <input type="text" name="txt_text" id="txt_text">
            <input type="number" name="txt_number" id="txt_number">
            <input type="email" name="txt_email" id="txt_email">
            <input type="tel" name="txt_tel" id="txt_tel">
            <input type="url" name="txt_url" id="txt_url">
    Copy after login

    Web page

    Multimedia

    Audio
        多媒体的dom对象有一些新的方法可以去做播放暂停
    Copy after login

    Single data source method

    默认界面:
    
            <audio src="music.mp3" controls="controls"></audio>
    
    自定义一个:
            <audio id="audio" src="music.mp3"></audio>
            <button id="btn">播放</button>
            <button id="btn_pause">暂停</button>
            <script>
            var btn = document.getElementById("btn");
            var btn_pause = document.getElementById("btn_pause");
            var audio = document.getElementById("audio");
            btn.addEventListener("click",function(){
                //播放音频
                audio.play();
            });
            btn_pause.addEventListener("click",function(){
                // 暂停音频
                audio.pause();
            });
            </script>
    Copy after login

    Multiple data source method

            <audio controls="controls">
                <source src="img/music.mp3" type="audio/mpeg"/>
            </audio>
    Copy after login

    Video

    Single data source method

    <video src="fun.mp4" controls="controls"></video>
    Copy after login

    Multiple data source method

            <video controls="controls" poster="top.png" autoplay="autoplay">
                 不同浏览器支持格式不一样,因为版权问题
                <source src="fun.ogg" type="video/ogg"></source>
                <source src="fun.mp4" type="video/mp4"></source>
                 当浏览器不兼容video标签,就会将他以p方式解析
                 用第三方组件代替
                 <object type="application/x-shockwave-flash" data="http://static.youku.com/v1.0.0557/v/swf/loader.swf" width="100%" height="100%" id="movie_player">
                  <param name="allowFullScreen" value="true">
                  <param name="allowscriptaccess" value="always">
                  <param name="allowFullScreenInteractive" value="true">
                  <param name="flashvars" value="VideoIDS=XMTMwNDAzNzM4NA==&amp;ShowId=0&amp;category=85&amp;Cp=0&amp;ev=1&amp;Light=on&amp;THX=off&amp;unCookie=0&amp;frame=0&amp;pvid=1439005764768c9QpaT&amp;uepflag=1&amp;Tid=0&amp;isAutoPlay=true&amp;Version=/v1.0.1080&amp;show_ce=0&amp;winType=interior&amp;Type=Folder&amp;Fid=25977506&amp;Pt=0&amp;Ob=1&amp;plchid=z&amp;openScanCode=1&amp;scanCodeText=&quot;限时&quot; 扫码免广告&amp;embedid=AjMyNjAwOTM0NgJ3d3cueW91a3UuY29tAi8=&amp;vext=bc%3D%26pid%3D1439005764768c9QpaT%26unCookie%3D0%26frame%3D0%26type%3D1%26fob%3D1%26fpo%3D0%26svt%3D0%26emb%3DAjMyNjAwOTM0NgJ3d3cueW91a3UuY29tAi8%3D%26dn%3D%E7%BD%91%E9%A1%B5%26hwc%3D1%26mtype%3Doth&amp;pageStartTime=1439005764766">
                  <param name="movie" value="http://static.youku.com/v1.0.0557/v/swf/loader.swf">
                  <p class="player_html5">
                    <p class="picture" style="height:100%">
                      <p style="line-height:460px;"><span style="font-size:18px">您还没有安装flash播放器,请点击<a href="http://www.adobe.com/go/getflash" target="_blank">这里</a>安装</span></p>
                    </p>
                  </p>
                </object>
            </video>
    Copy after login

    Video player related properties

            属性      值           描述
            autoplay    autoplay    如果出现该属性,则视频在就绪后马上播放
            controls    controls    如果出现该属性,则向用户显示控件,比如播放按钮
            height      pixels      设置视频播放器的高度
            loop        loop        如果出现该属性,则当媒介文件完成播放后再次开始播放
            muted       muted       规定视频的音频输出应该被静音。【即:静音】
            poster      URL         规定视频下载时显示的图像,或者在用户点击播放按钮前显示的图像
            preload     preload     如果出现该属性,则视频在页面加载时进行加载,并预备播放
                                    如果使用"autoplay",则忽略该属性
            src         url         要播放的视频的URL
            width       pixels      设置视频播放器的宽度
    Copy after login

    Subtitles

        字幕案例:
            <video id="clip" controls>
                <source src="fun.mp4" type="video/mp4" />
                <track label="English subtitles" kind="subtitles"
                srclang="en" src="video-subtitles-en.vtt" default />
            </video>
    
        字幕文件内容示例:
            WEBVIT  FILE
    
            1
            00:00:00.000 --> 00:00:12.000 D:vertical A:start
    
            2
            00:00:12.000 --> 00:00:15.300
            大家好,我是伟哥哥
    Copy after login

    Canvas

    2D

    3D (WebGL)

    SVG

    Scalable Vector Graphics Scalable Vector Shape

    svg

    ImageSource: via AI, File-->Script-->Save document as SVG

    svg can be like a tag Paste it directly to the page like that, but we prefer to load it like a picture

    可以借助三个标签载入:
    
            <iframe src="demo.svg" frameborder="0"></iframe>    //推荐
            <object data="demo.svg" type=""></object>
            <embed src="demo.svg" type="">
    
    
    学完ajax之后推荐方式:
    
            学习完异步请求之后,我们可以遍历所有SVG节点,把src引入进来,本身他是一个document对象,可以把它直接append到文档中。
    
            window.addEventListener('load',function(){
                var svgs = document.getElementByTagName('svg');
                for (var i = 0;i < svgs.length; i++){
                    //console.log(svg[i].dataset);
                    var src = $(svgs[i].data('src'));
                    //向服务器发送请求 得到svg
                    $.get(src,function(data){
                        var el = data.documentElement;
                        $(document.body).append($(el));
                        });
                }
                });
            同时将svg文件里面的style删除,以便我们进行更改样式
    Copy after login

    Additional:

    1. Sublime server plug-in installation

    Do not stop serber after installation. Directly
    exitsublime, otherwise sublime will crash

    2. Expand the settings in the upper right corner of the Google Chrome developer tools, select show useragent shadow DOM and you can see the virtual The DOM that comes out

    3.

    Pseudo classObject is equivalent to inserting one after weigege, and its style can be changed

    <style>
    .content::after{
        content: 'zuishuai';
        color: #465;
    }
    </style>
    <p class="content">weigege</p>
    Copy after login
    4.h5 new tag

    h5 The new tag may not be recognized by low-level browsers because it is too new. The unrecognized tag browser will automatically recognize it as p and load it. The tag can be generated in the following ways
    Method 1: Define it yourself

    Method 2: Introduce the third-party component html5shiv.js
    In it, all h5 new tags are created through method 1

    5. Enter the following code once in the Google console

    1.
    document.body (Enter)
    document.body.contentEditable = true; (Enter)
    Then you can edit the text directly on the page
    2.
    Enter directly at the connection
    data:text/html, (Enter)
    You can edit text directly on the page

    6. Third-party multimedia player library: jwplayer

    7. Specifically for mobile terminals Component used zepto?

    The implemented api is basically the same as jQuery
    Redundant processing and compatible codes have been cut off
    It seems that it can replace jQuery

    8.! important cannot support the inline style in the old version

    9.Markdown

    Open source project description files are written in this way
    Syntax link: http://wowubuntu.com/markdown/
    Use normal text to describe the syntax of rich text
    Extension md, markdown
    Case
    h tag

    HEADER1

    HEADER2

    HEADER3

    Write the paragraph directly without adding anything in front

    • Unordered list

    • There are spaces in front

    1. Ordered list

    2. The numbers in front are all ordered lists, remember to add spaces


    <br/>
    Copy after login


    SpecificEditorYou can add javascript to represent specific syntax for writing code

    10.iframe
    It is equivalent to digging a pit to load other pages

    The above is the detailed content of Notes organized by h5. For more information, please follow other related articles on the PHP Chinese website!

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Article

    Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    Nordhold: Fusion System, Explained
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Hot Topics

    Java Tutorial
    1667
    14
    PHP Tutorial
    1273
    29
    C# Tutorial
    1255
    24
    H5 Code: Best Practices for Web Developers H5 Code: Best Practices for Web Developers Apr 16, 2025 am 12:14 AM

    Best practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.

    H5: The Evolution of Web Standards and Technologies H5: The Evolution of Web Standards and Technologies Apr 15, 2025 am 12:12 AM

    Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.

    Is H5 a Shorthand for HTML5? Exploring the Details Is H5 a Shorthand for HTML5? Exploring the Details Apr 14, 2025 am 12:05 AM

    H5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.

    H5 and HTML5: Commonly Used Terms in Web Development H5 and HTML5: Commonly Used Terms in Web Development Apr 13, 2025 am 12:01 AM

    H5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.

    Understanding H5 Code: The Fundamentals of HTML5 Understanding H5 Code: The Fundamentals of HTML5 Apr 17, 2025 am 12:08 AM

    HTML5 is a key technology for building modern web pages, providing many new elements and features. 1. HTML5 introduces semantic elements such as, , etc., which enhances web page structure and SEO. 2. Support multimedia elements and embed media without plug-ins. 3. Forms enhance new input types and verification properties, simplifying the verification process. 4. Offer offline and local storage functions to improve web page performance and user experience.

    H5: How It Enhances User Experience on the Web H5: How It Enhances User Experience on the Web Apr 19, 2025 am 12:08 AM

    H5 improves web user experience with multimedia support, offline storage and performance optimization. 1) Multimedia support: H5 and elements simplify development and improve user experience. 2) Offline storage: WebStorage and IndexedDB allow offline use to improve the experience. 3) Performance optimization: WebWorkers and elements optimize performance to reduce bandwidth consumption.

    Deconstructing H5 Code: Tags, Elements, and Attributes Deconstructing H5 Code: Tags, Elements, and Attributes Apr 18, 2025 am 12:06 AM

    HTML5 code consists of tags, elements and attributes: 1. The tag defines the content type and is surrounded by angle brackets, such as. 2. Elements are composed of start tags, contents and end tags, such as contents. 3. Attributes define key-value pairs in the start tag, enhance functions, such as. These are the basic units for building web structure.

    The Building Blocks of H5 Code: Key Elements and Their Purpose The Building Blocks of H5 Code: Key Elements and Their Purpose Apr 23, 2025 am 12:09 AM

    Key elements of HTML5 include,,,,,, etc., which are used to build modern web pages. 1. Define the head content, 2. Used to navigate the link, 3. Represent the content of independent articles, 4. Organize the page content, 5. Display the sidebar content, 6. Define the footer, these elements enhance the structure and functionality of the web page.

    See all articles