2

Is it possible to build an html webpage entirely out of javascript? Would you need anchors like some div elements to organize things?

6
  • No, you can't show anything in a browser without HTML. You can create that HTML with JS, though. Commented Apr 6, 2021 at 19:20
  • 1
    I am saying if you could take the entire thing and use javascript to build the entire html file on load Commented Apr 6, 2021 at 19:21
  • 3
    You'd still need a script tag, that's HTML too. Commented Apr 6, 2021 at 19:22
  • Very good point. Thank you Commented Apr 6, 2021 at 19:22
  • 4
    At a minimum you need a script tag (plus the HTML boilerplate - DOCTYPE, html, head, body etc. - to be properly valid). Commented Apr 6, 2021 at 19:23

1 Answer 1

2

No, you cant build an entire website out of javascript BUT if the question is can you build the website using javascript into HTML, CSS, etc yes. At the end of the day HTML and CSS is just text you can easily form these files from javascript.

Sign up to request clarification or add additional context in comments.

2 Comments

I think the answer is YES you can have no HTML file and still have a webpage. In fact you will need not to create an HTML file using JS also. There are so many template engines out there like hbs, ejs, pug, asp., etc etc
@KartikMalik The template engines are another story, they're hardly scoped to JavaScript only. Of course you can write a .js file and serve that from a Node.js server, but a browser still can't show anything if the loaded file doesn't contain HTML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.