Monu Tools

Định dạng HTML

Làm đẹp HTML với thụt lề nhận biết khối, hoặc thu gọn nó. Nội dung của pre, textarea, script và style được giữ nguyên.

Cách dùng Định dạng HTML

  1. 01

    Dán HTML của bạn vào ô đầu vào.

  2. 02

    Chọn Làm đẹp để thụt lề hoặc Thu gọn để nén.

  3. 03

    Chọn kích thước thụt lề, rồi sao chép kết quả.

What the HTML formatter does

This is an HTML formatter that beautifies markup with block and inline aware indentation, or minifies it by collapsing whitespace and stripping comments. You pick the indent size when beautifying.

Beautifying indents elements according to how they nest, so the structure of a document, which elements contain which, becomes obvious. That makes hand-written or generated HTML far easier to read and debug.

Both beautify and minify run entirely in your browser, so your markup never leaves your device.

Elements it leaves untouched

It deliberately leaves the contents of pre, textarea, script and style untouched, because whitespace inside those elements is significant: reformatting them would change preformatted text, what users type, or the meaning of your code.

How minifying works

Minifying removes comments and collapses runs of whitespace, which trims the file size browsers have to download. It is most useful as a build step for production pages.

Why it keeps a space between tags

The minifier keeps a single space between tags rather than removing it entirely, because whitespace between inline elements is actually rendered, and dropping it can shift your layout. This caution avoids the subtle visual bugs aggressive minifiers can cause.

Câu hỏi thường gặp

Làm đẹp HTML làm gì?

Nó thụt lề các phần tử dựa trên cách lồng nhau và cấu trúc của chúng, đồng thời để nguyên nội dung của pre, textarea, script và style, vì khoảng trắng ở đó có ý nghĩa.

Thu gọn HTML hoạt động như thế nào?

Nó loại bỏ chú thích và gộp các chuỗi khoảng trắng thành một dấu cách. Nó giữ một dấu cách giữa các thẻ thay vì loại bỏ chúng, vì khoảng trắng giữa các phần tử nội tuyến được hiển thị và bỏ nó đi có thể làm dịch chuyển bố cục.

HTML của tôi có được gửi đến máy chủ không?

Không. Cả Làm đẹp và Thu gọn đều chạy hoàn toàn trong trình duyệt của bạn, nên mã đánh dấu của bạn không bao giờ rời khỏi thiết bị.

Nguồn

Nhúng công cụ này

Thêm công cụ này vào trang web của riêng bạn. Sao chép đoạn mã bên dưới; nó tự động cập nhật.

<iframe src="https://monu.tools/embed/vi/html-formatter" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>

Công cụ liên quan