22 HTML5 tips

Source: Internet
Author: User
Tags valid email address

1. New Document Type (Doctype) <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> Are you still using this troublesome and hard-to-remember XHTML document type? If this is the case, you should switch to the new HTML5 document type. <! DOCTYPE html> now only 15 characters are needed. (Note: Your doctype statement must appear in the first line of your html file .) 2. Are you still considering using the following code to mark the image (Figure) element? <Mg src = "path/to/image" alt = "About image"/> <p> Image of Mars. </p> the above Code cannot be associated with the title of the image in a simple and semantic manner, because it is only wrapped with paragraph tags and image elements, HTML5 has improved this by introducing the <figure> element. When combined with the <figcaption> element, we can match the title of the image with the image. The Code is as follows: <figure> <figcaption> <p> This is an image of something interesting. </p> </figcaption> </figure> 3. you can use the <small> element to create a subtitle that is closely related to the logo. However, now HTML5 has modified this usage. The <small> element is redefined, or, more appropriately, it is used to represent a small word or other side note (for example, copyright statement at the bottom of the website ). 4. You no longer need scripts or link types. You may still add type attributes to your links and script tags like the following code. <Link rel = "stylesheet" href = "path/to/stylesheet.css" type = "text/css"/> <script type = "text/javascript" src = "path/ /script. js "> </script> In HTML5, this is no longer needed. It means that these two labels represent the style and script respectively. Therefore, we can delete all their type attributes. The Code is as follows: <link rel = "stylesheet" href = "path/to/stylesheet.css"/> <script src = "path/to/script. js "> </script> 5. use or not use quotation marks. HTML5 is different from XHTML. If you do not like it, you do not need to enclose the attribute with quotation marks. However, if you think that using quotation marks will make you feel more comfortable, of course there will be no problems. <P class = myClass id = someId> Start the reactor.6. edit your content. One of the most powerful functions of HTML5 is "contenteditable ", as its name implies, it will allow users to edit any text content contained in an element (including its child elements. It is widely used, for example, simple task list or wiki-based site. In addition, it also has the advantage of using local storage. <! DOCTYPE html>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.