I am trying to get namespaces written in an external css (two separate files actually). When I run the file on my browser it will not use the declared namespaces. I think that t
In your XHTML:
Your markup is not well-formed:
Your XML declaration should come first, then your doctype declaration:
Some of your tags aren't closed properly, they should be:
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:
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:
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:
It's font-weight: bold
, not font-style: bold
.
It's font-style: italic
, not font-style: italics
.
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?