Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1838624
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:30:12+00:00 2026-05-17T06:30:12+00:00

Facelets relies on XML namespaces to work with XHTML. How are HTML 4, and

  • 0

Facelets relies on XML namespaces to work with XHTML. How are HTML 4, and as far as I know, HTML 5 do not support namespaces. Also HTML 5 has some new elements that are not available in XHTML. Even HTML 4 and XHTML have some differences regarding elements and attributes they support.

The question is: Is it possible to render HTML 4/5 documents using Facelets? If so, how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:30:13+00:00Added an answer on May 17, 2026 at 6:30 am

    Since Facelets is a XML based view technology which eats and emits in essence XML markup, you cannot use it with a HTML4 doctype. The HTML4 doctype describes several elements which cannot be self-closing, like <link>, <meta>, <br> and <hr>. However, with XML you’re forced to close them like <link/>, <meta/>, etc. So using a HTML4 doctype is absolutely not an option for Facelets (that is, when you respect the standards and/or fear the w3 validator, it will however work perfectly on the most if not all webbrowsers).

    HTML5, on the other hand, allows XML markup. This is specified in chapter 3.2.2 – Elements:

    Example:

    <link type="text/css" href="style.css"/>
    

    Authors may optionally choose to use this same syntax for void elements in the HTML syntax as well. Some authors also choose to include whitespace before the slash, however this is not necessary. (Using whitespace in that fashion is a convention inherited from the compatibility guidelines in XHTML 1.0, Appendix C.)

    I myself use <!DOCTYPE html> all the way, also with JSF/Facelets, even without a <?xml?> declaration in top of the page. It works perfectly in all browsers.

    As per your arguments:

    HTML 5 do not support namespaces.

    This doesn’t matter. The namespaces are only of interest for the XML based server side view technology (like as Facelets) which in turn can generate pure HTML with those tags. The following example is legitimately valid for Facelets:

    <!DOCTYPE html>
    <html lang="en"
        xmlns:f="http://xmlns.jcp.org/jsf/core" 
        xmlns:h="http://xmlns.jcp.org/jsf/html">
        <h:head>
            <title>Title</title>
        </h:head>
        <h:body>
            <h:outputText value="#{bean.text}" />
        </h:body>
    </html>
    

    This renders legitimately valid HTML5 (for the client side):

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <title>Title</title>
        </head>
        <body>
            Some text
        </body>
    </html>
    

    You see, Facelets already removes the XHTML declarations since they have no meaning in the client side.

    And,

    Also HTML 5 has some new elements that are not available in XHTML

    this make also no sense. It’s all about the generated output. Which can be HTML5 as good. Your only problem may be the browser support and the availability of 3rd party JSF components which renders HTML5 specific elements. Since JSF 2.2, it’s possible to use the new passthrough elements feature to turn custom elements into a JSF component. Simply give the HTML5 element a jsf:id attribute. It’ll transparently internally be interpreted as a UIPanel instance in the JSF component tree (like <h:panelGroup>).

    <!DOCTYPE html>
    <html lang="en"
        xmlns:jsf="http://xmlns.jcp.org/jsf"
        xmlns:f="http://xmlns.jcp.org/jsf/core" 
        xmlns:h="http://xmlns.jcp.org/jsf/html"
    >
        <h:head>
            <title>Title</title>
        </h:head>
        <h:body>
            <header jsf:id="header">Header</header>
            <nav jsf:id="nav">Nav</nav>
            <main jsf:id="main">Main</main>
            <footer jsf:id="footer">Footer</footer>
        </h:body>
    </html>
    

    You can even reference it from ajax as in <f:ajax render="main">.

    Actually, XHTML is overhyped. Its sole intent is to ease HTML development using XML based tools which can manipulate/transform/generate HTML pages on the server side (like as Facelets). But some starters also use it without using any XML tool and output it plain as-is, because it’s "so cool" -for some unclear reason. Do note that it’s even considered harmful to do so.

    In a nutshell, XHTML is great as server side view technology, but simply not as client side markup technology. It has utterly no value at the client side.

    See also:

    • Our XHTML wiki page
    • How should a <!DOCTYPE> section look in JSF? HTML5 or XHTML?
    • JavaServer Faces 2.2 and HTML5 support, why is XHTML still being used
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using JSF/Facelets, and I'm trying to iterate over some Document objects (custom object)
In my JSF/Facelets app, here's a simplified version of part of my form: <h:form
I would like to use JavaScript to manipulate hidden input fields in a JSF/Facelets
I`m developing an application using Spring WebFlow 2, Facelets and JSF. One of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.