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 6657649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:47:42+00:00 2026-05-26T01:47:42+00:00

Possible Duplicate: How to create xhtml elements with javascript Creating a <br /> with

  • 0

Possible Duplicate:
How to create xhtml elements with javascript
Creating a <br /> with javascript createElement?

I’m working with the programmatic generation of forms with JavaScript, e.g.:

document.createElement();
document.appendChild;
inputExample.type = "text";
…

but I realized that the JavaScript generation of self-closing [X]HTML/XML elements isn’t applicable, i.e.

document.createElement('input');

will result in <input>, not <input />.

While the page has a

<!DOCTYPE html>

and

<html xmlns="http://www.w3.org/1999/xhtml">…</html>

and is part of a browser extension thus being interpreted with a MIME type of text/html, therefore not needing to syntactically conform to XHTML, I would like to know of a way for JavaScript element creation to generate valid XHTML. Is there a way to do this?

  • 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-26T01:47:42+00:00Added an answer on May 26, 2026 at 1:47 am

    When you call createElement, you are creating a DOM object, there is no markup involved. The only mechanisms for generating markup are the innerHTML and outerHTML properties that have been standardised to some extent in HTML5.

    Those properties should generate markup using the HTML fragment serialization algorithm in an HTML document or the XML fragment serialization algorithm in an XML document. Perhaps the properties should have been called innerMarkup and outerMarkup.

    I don’t think there is any way to call one serialiser or the other specifically using script (e.g. to call the XML serializer from within an HTML document), though you may be able to parse trivial markup from the HTML serialiser and turn it into something approximating XHTML.

    By the way, as far as I know there is no such thing as “XHTML5”. The current standard for HTML is version 4.01. HTML5 is a working draft that may never be standardised. There are also XHTML 1.0 and XHTML 1.1 that are used as DOCTYPEs in documents that are nearly always served as text/HTML (to serve them as anything else would not be sensible) and so are treated as HTML documents.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to create my own JavaScript Random Number generator that I can
Possible Duplicate: Custom alert using Javascript I want to create a confirmation message-Do you
Possible Duplicate: LSUIElement not working I am using Jar Bundler to create a .app
Possible Duplicate: How to create a GUID / UUID in Javascript? I need to
Possible Duplicate: Javascript create variable from its name The code below checks to see
Possible Duplicate: javascript create INcode workspace (framework) In the last few days i have
Possible Duplicate: Create a temporary directory in Java Duplicate: stackoverflow.com/questions/375910 Is there a way
Possible Duplicate: Create Excel file in Java How to save output in excel format
Possible Duplicate: How I can create installer for website. PHP mysql I'm looking to
Possible Duplicate: When to choose checked and unchecked exceptions When should I create a

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.