trouble getting declared namespaces to work

南笙酒味 提交于 2019-12-02 04:06:27
BoltClock

In your XHTML:

  1. Your markup is not well-formed:

    • Your XML declaration should come first, then your doctype declaration:

      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    • Some of your <link /> tags aren't closed properly, they should be:

      <link rel="stylesheet" href="movies.css"  type="text/css" />
      <link rel="stylesheet" href="actors.css" type="text/css" />
      
  2. Your page must be served as application/xhtml+xml by the server. Typical servers don't know that you're serving XHTML, so they send them as text/html instead. Browsers won't be able to treat text/html files as XML, so they won't apply CSS to your custom XML elements.

    If you work with PHP, it's simply a matter of adding this to the very top of your XHTML file:

    <?php header('Content-Type: application/xhtml+xml'); ?>
    

    Or in ASP, add this:

    <% Response.ContentType = "application/xhtml+xml"; %>
    

    You should also have an accompanying meta tag, but it's not necessary for your page to validate, and browsers ignore it anyway:

    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    

    You can find a short history lesson on UAs treating XHTML as HTML tag soup in this answer to better understand this.

In your CSS:

  1. It's font-weight: bold, not font-style: bold.

  2. It's font-style: italic, not font-style: italics.

  3. Make sure that your @namespace statements are placed at the beginning of your stylesheets. From the spec:

    Any @namespace rules must follow all @charset and @import rules and precede all other non-ignored at-rules and rule sets in a style sheet.


But with all that said, why aren't you placing your actors and movies into their own XML files, then transforming them using XSLT into familiar, actual XHTML?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!