Fix error: "Content after discarding document element"--HTML5 new feature, local style sheet

Source: Internet
Author: User

Recently learning Angularjs, but this article and angularjs not much relationship. After learning to use the route and Ng-view using the template, after discovering that the view is loaded, Firefox will report an error "discard the contents of the document Element", although the page is running normally, but always look awkward: (.

After careful review, found that the error points to the style sheet tag style of the end, this reflects: the original is a full HTML page, style sheet in the head tag is not a problem, but now these various view templates themselves use some of the styles are directly written to the template, So not in the head of the entire page, the HTML protocol is not supported! Although these styles are very simple, local features dedicated, but previously if you want to solve this problem, can only be built an entire style file of an app, the use of class to solve, you need a style for each function of the name, and then to each element reference, but this is not only troublesome, and Trouble! Because you can't write a generic style to an element! Very not reconciled, went to W3school, carefully studied the HTML5 document, found that HTML5 has supported the local style sheet ^_^. However, there are two requirements, the first need to be placed within a parent element, the second add property scoped. The modified template is as follows:

<DivID= "View-xxx">    <stylescoped= "scoped">A{}thead TR{}tbody TR{}    </style>    ...</Div><!--End of view -

Reload to see the perfect solution!

Fix error: "Content after discarding document element"--HTML5 new feature, local style sheet

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.