Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on Splitting a large HTML file into two or more HTML files without JavaScript

Post

Splitting a large HTML file into two or more HTML files without JavaScript

+2
−2

I am developing a modular HTML-PHP-CSS no-JavaScript (JavaScriptless) contact form and the HTML is becoming increasingly large, around 80 lines (and could easily grow to be significantly larger as to say 160 lines), many of which are currently very broad (due to many HTML attributes and nesting) and require horizontal scrolling to edit, which is uncomfortable and raises the chance for typos which could break the code.

Is there a way to split the HTML file into several HTML files without JavaScript and without PHP (an HTML-only soulution)?

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

3 comment threads

Just Add Line Breaks (9 comments)
I am not exactly sure whether you are asking for a PHP-based or purely HTML-based solution. You didn'... (3 comments)
use iframe (1 comment)
Just Add Line Breaks
manassehkatz‭ wrote almost 3 years ago · edited almost 3 years ago

Generally speaking, HTML doesn't care about white space. When I have this issue, I reformat with, at a minimum, a line break after each closing tag < / whatever >. But you can add more line breaks wherever you want. As far as length of the file (# of lines), why does that matter? 80 lines - or double or triple with shorter lines - is "nothing".

deleted user wrote almost 3 years ago

For me too many blank lines is something and by principle I want to keep the HTML files small, up to 25 lines each, without too much nesting, maybe I should create a "multi page" form, instead the current "single page" one, but to be efficient it must include JavaScript, I guess (one backend page with 3-4 frontend pages).

manassehkatz‭ wrote almost 3 years ago

You can't have it all. You can: Use a different language (PHP or other) generating HTML using more traditional coding - lots of lines of code but more structured than "blob of HTML"; have big HTML files (a few long lines or lots of short lines - just a question of line breaks for readability); or totally change the user experience by changing to multiple small separate pages linked by form submission.

manassehkatz‭ wrote almost 3 years ago

The problem with the last choice is it sacrifices usability/functionality for an IMHO misguided sense of "style". Remember, the user may or may not ever see the actual HTML (most won't, and the ones that do will be mostly curious programmers and 80 lines won't bother them a bit) but they will be immediately affected by an arbitrary split of the user interaction to multiple pages.

hkotsubo‭ wrote almost 3 years ago

I'm afraid you're focusing on the wrong issues. 80 lines is not large, and nesting is good to make things easy and convenient for the dev team: it makes the code clearer and easier to understand and maintain (on the other hand, keeping everything in one non-nested line just for the sake of having fewer lines is usually a bad idea, from the maintenance point of view). If you care about the final size of your pages, consider using minifiers and/or enabling compression in your web server.

deleted user wrote almost 3 years ago

@hkotsubo‭ I generally disagree ; I do agree that nesting is good and use it generally wherever I can but it doesn't do with the subjective and case-specific feeling when something is just over the top. Maybe I should clarify that I want to prevent a situation were it becomes 120 lines instead 80.

hkotsubo‭ wrote almost 3 years ago

Perhaps you should edit and clarify the question. At least for me, I'm failing to see what the actual problem is. Why can't you use PHP (as you confirmed you're already using) as some include's will do the job, and why limiting the number of lines is such a serious issue/requirement (so "serious" that you're willing to sacrifice code clarity and maintainability just to have fewer lines)?

deleted user wrote almost 3 years ago

@hkotsubo‭ I have already edited the question, you are welcome to review.

in general I separate HTML from PHP; I don't want to use PHP for creating rather static HTML that I can easily create and change by myself.

As I have tried to clue, for me, having something like 80 lines (with the amount of lines might easily grow larger to say 120 lines) all of this with very broad and horizontal scrolling required to edit almost every line is in my mind inefficient.

hkotsubo‭ wrote almost 3 years ago

If I understood correctly, maybe what you actually need is a Static Site Generator: https://snipcart.com/blog/choose-best-static-site-generator (I use Jekyll for my personal blog, BTW). Not sure if that's what you're looking for, but take a look at the concept in general, maybe it's a different approach that might fit your needs