简体   繁体   中英

How to add line breaks in jumbled html code

I have html code that looks all mashed up like:

<html><head> <script type="text/javascript"> window.onload = runJcript('fixads()');</script> <link rel="stylesheet" href="http://wik253.googlecode.com/files/jquery.ui.all.css" type="text/css"> <link rel="stylesheet" href="http://wik253.googlecode.com/files/main5.css" type="text/css"> </head><body></body>

It is very hard to read and work with, Is there a way to bring it to proper format like:

<html>
<head>
 <script type="text/javascript"> window.onload = runJcript('fixads()');
</script> 
<link rel="stylesheet" href="http://wik253.googlecode.com/files/jquery.ui.all.css" type="text/css"> 
<link rel="stylesheet" href="http://wik253.googlecode.com/files/main5.css" type="text/css"> </head>
<body>
</body>
</html>

So its more readable and workable. Is their a tool or an online script that can help me do that?

Thanks, Praney

If you are using a text editor which is written for coding it is common that the editor has a function for cleaning up the indentation. In Kate you find the function under Tools > Clean Indentation.

If you are generating HTML you could take a look at HTML Tidy: http://tidy.sourceforge.net/

Depends on your use case. If you just need to do it for a few documents here and there, you can use a beautifier like: http://jsbeautifier.org/ (beautifies HTML code too)

If you need it in your application, you can check out the js-beautify engine that powers the site above: https://github.com/einars/js-beautify

You can use HTML Tidy, there's an online version over here . Or you can download it to use in your application here .

Many IDE's have clean-up options like Dreamweaver.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM