• 0

[pic]What beautiful HTML looks like


Question

19 answers to this question

Recommended Posts

  • 0

Code isn't meant to be beautiful. It's the part designers don't want you to see. :laugh:

That's just clean code which will help the developer or anyone who's interested in the makeup of the site to read it easier.

  • 0
Gah, but how do you get the HTML to be tabbed correctly when your generating it in PHP, mine always goes to the ****. :(

I cheat by running it through an XSLT transformation that does pretty printing and such.

Makes it much easier if you start out writing it as proper HTML5 code.

  • 0

I assumed this was going to be a joke

and btw, there is nothing beautiful about that code ;) The php includes for starters are very ugly and potentially messy. And why would you use UTF-8 encoding and still replace every non ascii character with it's html entity. Another one who doesn't know **** about character sets (far too many of those people on this world i'm afraid)

Edited by XerXis
  • 0

HTML5 is already in use in the majority of browsers and sites.

HTML5 is just a standardisation of practises already in use, the parsing algorithm is based on what IE/Safari/Mozilla/Opera did. Old IE only extensions are being promoted to being part of HTML5 if they're useful (and it means the implementations in other browsers are no longer mimicking IE, they're standard)

  • 0
Gah, but how do you get the HTML to be tabbed correctly when your generating it in PHP, mine always goes to the ****. :(

Is there any need for php to generate html tidy? The point of making it tidy is to make it easy to read and edit... but the view source isn't the code you are editing, it should be the php thats tidy, not the outputted html.

I suppose it could potentially help with debugging formatting, but if you get your html clean before you throw php around it will always be right.

  • 0

Beauty is in the eye of the beholder. Somebody may consider this code professional because it is neatly indented. I consider it amateurish because the author is using inline PHP, and in a .HTML document, which would never even parse the code unless he re-configured his server mime type handling, no less.

I seriously urge any budding developers who look at this picture not to take it to heart. Anybody focusing on on their code being "pretty" is most likely doing so because they don't know enough to focus on functionality. In the real world, not only is this a waste of time but it can actually impact your applications negatively.

Just the other day, I noticed my new PHP developer indenting the search result HTML in one of our web applications. In this particular application, an average query yields about 1,000 results, all of which have to be displayed for the client without pagination. Simply removing the indentation my apprentice put in reduced the uncompressed output from the 600KB range to about 250KB.

  • 0
Is there any need for php to generate html tidy? The point of making it tidy is to make it easy to read and edit... but the view source isn't the code you are editing, it should be the php thats tidy, not the outputted html.

I suppose it could potentially help with debugging formatting, but if you get your html clean before you throw php around it will always be right.

Mostly so it looks professional and it also helps with debugging when your PHP generated section isn't off the screen because of tabbing. :p

I wouldn't mind knowing about this XSLT trick as well if its possible.

  • 0

I use output buffering in a shared file to grab the result of the PHP script, then run it through a function that creates an XSLT processor based on a file (http://alex.thefrapp.com/pretty_print.xsl), and then runs the PHP output through it, then I output the result.

The shared file basically detects the user agent and runs one of 2 output functions based on the buffer (if it's HTML, it outputs the HTML5 doctype and changes "/>" into ">", if it's XHTML it runs it through the XSLT file while outputting the proper XML namespaces and PI).

  • 0

Hmm, I did some googling and I came across the Tidy Class, which is built into PHP on windows and an extension on other platforms.

	$out2 = ob_get_contents();

ob_end_clean();
$tidy = new tidy();
$config = array('indent' => TRUE,
				'output-xhtml' => TRUE,
				'wrap' => 200,
				'indent-spaces' => 6);
$tidy->parseString($out2, $config, 'UTF8');
$tidy->cleanRepair();
echo $tidy;

Not sure if it will have any negative affects on a live site, might be worth doing only locally.

  • 0
Beauty is in the eye of the beholder. Somebody may consider this code professional because it is neatly indented. I consider it amateurish because the author is using inline PHP, and in a .HTML document, which would never even parse the code unless he re-configured his server mime type handling, no less.

I seriously urge any budding developers who look at this picture not to take it to heart. Anybody focusing on on their code being "pretty" is most likely doing so because they don't know enough to focus on functionality. In the real world, not only is this a waste of time but it can actually impact your applications negatively.

Regarding "pretty code", it's been my experience that developers who are anal about how their source code is formatted also tend to be anal about the quality of their code.

The few developers that I've worked with who were really inconsistent with their source code formatting were also pretty useless at application design, as if their inability to be consistent with their code formatting pointed to some deeper inability to marshal components together in a logical fashion.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • RevPDF 4.5.0 by Razvan Serea RevPDF is a free, fully offline PDF editor for Windows, macOS, and Linux that lets you edit text and images directly inside PDF files — no internet connection, no account, and no cloud uploads required. Unlike bloated alternatives that demand subscriptions and constant connectivity, RevPDF fits in under 60MB on desktop while delivering a complete editing toolkit: annotate, redact, sign, compress, split, merge, convert, and reorganize pages, all processed locally on your device. Smart font matching ensures edited text blends seamlessly with the original, and multi-language support includes RTL scripts such as Arabic and Hebrew. Where most PDF editors force you to choose between features and simplicity, RevPDF manages both. You can build interactive forms from scratch with text fields, checkboxes, and dropdowns, permanently redact sensitive data before sharing, draw freehand on contracts and diagrams, and add custom watermarks — all without a single file leaving your machine. Edit Text and Images Directly Inside PDFs RevPDF supports true inline PDF editing — not just annotation layers on top of a document, but actual modification of existing text and images within the file. A smart font-matching engine identifies the font used in the original document and applies it automatically when you make edits, so changes blend naturally with the surrounding content. You can reposition elements, resize images, and update text across single pages or entire documents. RevPDF 4.5.0 release notes: This is one of the biggest updates to RevPDF yet. A lot of things people have been asking for are finally here. New Features Auto Redaction Permanently redact sensitive text and areas from your PDFs before sharing. Clean, irreversible, and fully offline. Comments, Links & Bookmarks Add comments for review, insert clickable links, and create bookmarks to jump around long documents without scrolling forever. Find & Replace Search across the whole document and replace text in one go. Long overdue. Split Pages Vertically or Horizontally Split any page down the middle, vertically or horizontally. Perfect for scanned books or double-page spreads. New Drawing Tools More tools for freehand drawing and markup, better for annotations, sketches, and detailed notes. Continuous Scrolling in Editor The editor now scrolls continuously through pages instead of jumping between them. Working through long documents is a lot smoother now. PDF Metadata Editor View and edit the metadata stored inside your PDFs, including title, author, subject, and keywords. Better Font Matching Text edits now blend in more naturally by doing a better job of matching the original font. Tabbed PDF Viewer Open multiple PDFs at once in tabs and switch between them without going back to the home screen. Add Links Insert hyperlinks anywhere in your PDF, to external URLs or to other pages within the document. Share & Print Shortcuts Share or print directly from the editing screen, home screen, and viewer. No extra steps. Minor Updates Paste images directly from clipboard into your PDF New image editing tools for more control over images inside documents Bug Fixes Fixed file saving issues on Windows and Linux Everything still works fully offline. No login, no cloud, no account. Your files stay on your device. Download: RevPDF 4.5.0 | 58.0 MB (Open Source) Links: RevPDF Home Page | Github | Screenshots 1 | 2 Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Interesting. I'm not using a VPN with my phone. I tried though my home internet (Rogers) and my cellular internet (Telus) and both trigger the dialog above.
    • Three days after Anthropic launched Claude Fable 5 as the most capable AI model it had ever released to the public, the United States government ordered it switched off — and now the company is refunding customers who paid to use a product that vanished almost overnight https://www.techtimes.com/articles/318342/20260613/us-government-pulls-anthropics-fable-5-offline-now-come-refunds-vanished-ai.htm  
    • Microsoft fired the team and replaced them with AI and this is what you get.
    • iPhone 18 Pro Camera Goes Mechanical: Variable Aperture, 2nm Chip, Dark Cherry Due September https://www.techtimes.com/arti...rk-cherry-due-september.htm Apple Liquid Glass iOS 27: WWDC 2026 Brings Refinements Developers Must Adopt Today https://www.techtimes.com/arti...lopers-must-adopt-today.htm Apple WWDC 2026: Siri Rebuilt on Gemini, homeOS Previewed in Cook Farewell Keynote https://www.techtimes.com/arti...d-cook-farewell-keynote.htm
  • Recent Achievements

    • Week One Done
      agatameier earned a badge
      Week One Done
    • One Month Later
      agatameier earned a badge
      One Month Later
    • Week One Done
      ssd21345 earned a badge
      Week One Done
    • Contributor
      MarkHughes4096 went up a rank
      Contributor
    • Dedicated
      jordanspringer earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      507
    2. 2
      +Edouard
      175
    3. 3
      PsYcHoKiLLa
      139
    4. 4
      ATLien_0
      90
    5. 5
      Steven P.
      76
  • Tell a friend

    Love Neowin? Tell a friend!