The <?xml-stylesheet?> Instruction for HTML 5
The <?xml-stylesheet?>
processing instruction can be used to reference XSLT style sheets with templates containing HTML code and transformation instructions.
Creating a style sheet for a web site has a number of advantages:
- Site-wide style sheets with logos and navigation can be updated to easily change the look and feel of the entire web site or used to create multiple sites each with a different appearance from the same source of content.
- Moving repetitive code from web pages into style sheets makes the actual content of those pages more prominent, which helps improve search engine optimization.
- Different style sheets can be used for different devices, making it easier to repurpose the same content for mobile devices in addition to desktop-based browsers.
- Style sheet files can be cached on the client side by web browsers and reused as new pages are loaded without having to download them again for each page.
- The W3C Fix for Internet Explorer, which allows sending year 2000 and later HTML code to Internet Explorer (IE 6, IE 7 and IE 8) consists primarily of adding an
xml-stylesheet
instruction to the HTML document. - Some code needed for Internet Explorer, such as the
X-UA-Compatible
meta tag, causes HTML validation errors. The code can be put into a style sheet to avoid those validation errors.
Templates in a style sheet can serve various purposes:
- templates can be used for navigation areas, possibly using HTML 5 menus, which put the same links on every page and provides a way to easily change navigation links across the entire site
- templates can be used for other common elements rather than including them on every page, which improves page load times
- templates can be used to add sections, such as a header or footer, with content that can easily be updated in one place by simply changing it in the template