-2

I'm looking for a script to replace

<br>

with

<br />

Also looking to change

border=0

into

border="0"

Is this possible to do so that I could pass w3c compliance? Thanks in advance - Dave

  • 2
    It'd be simpler to change your DOCTYPE to "html" :-) – Pointy Apr 18 '12 at 22:01
  • I hope you're not looking for a javascript script to do that. That would be silly. – Mike Robinson Apr 18 '12 at 22:02
  • A script? Are you planning to run this on the browser? The sources (or the HTML generation) needs to be fixed... – Lucero Apr 18 '12 at 22:03
  • Are you wanting use JS to fix your code client-side? There's not much point, the horse has left the barn at that point. – Surreal Dreams Apr 18 '12 at 22:03
  • 1
    I guess you would do the replace in multiple files? most text editors will allow you to open up a project folder and do a project wide find&replace – alex Apr 18 '12 at 22:04

2 Answers2

1

To answer your question no, it won't. It's not that javascript isn't capable of replacing and/or fixing malformed tags but by the time your script runs the html has already been parsed.

Spencer Ruport
  • 34,865
  • 12
  • 85
  • 147
0

Im not sure what you looking for but for that kind of changes I use find and replace in the HTML files if you can have access to them. Don't forget to chose the option to replace in all files open or in the solution.

Your changes are not enough complicated to use a regular expression. And it would be a bad idea to run a javascript script every time instead of fixing it once.

Marc
  • 16,170
  • 20
  • 76
  • 119