{"id":8310557,"date":"2025-09-10T11:46:43","date_gmt":"2025-09-10T08:46:43","guid":{"rendered":"https:\/\/elementor.com\/tools\/?p=8310557"},"modified":"2025-09-10T11:49:45","modified_gmt":"2025-09-10T08:49:45","slug":"html-line-counter","status":"publish","type":"post","link":"https:\/\/elementor.com\/tools\/html-line-counter\/","title":{"rendered":"HTML Line Counter"},"content":{"rendered":"\t\t<div data-elementor-type=\"container\" data-elementor-id=\"8310555\" class=\"elementor elementor-8310555\" data-elementor-post-type=\"elementor_library\">\n\t\t\t\t<div class=\"elementor-element elementor-element-23691a2c e-flex e-con-boxed e-con e-parent\" data-id=\"23691a2c\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-37c3711c elementor-widget elementor-widget-html\" data-id=\"37c3711c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<style>\r\n    \/* === Main App Container === *\/\r\n    .html-viewer-app {\r\n        width: 100%;\r\n        max-width: 800px; \/* Adjusted for a single-box layout *\/\r\n        margin: 0 auto;\r\n        padding: 60px 0 0;\r\n        background: transparent;\r\n        overflow: visible;\r\n        position: relative;\r\n    }\r\n\r\n    \/* === Main Content Area (Single Box) === *\/\r\n    .input-section {\r\n        width: 100%;\r\n        height: 460px;\r\n        display: flex;\r\n        flex-direction: column;\r\n        background: white;\r\n        border-radius: 8px;\r\n        overflow: hidden;\r\n        box-shadow: 0 4px 15px rgba(0,0,0,0.08); \/* Added a subtle shadow for depth *\/\r\n    }\r\n\r\n    .section-header {\r\n        background-color: #05047E;\r\n        color: white;\r\n        padding: 12px 20px;\r\n        font-family: 'DM Sans', sans-serif;\r\n        font-weight: 500;\r\n        font-size: 1.125rem;\r\n        display: flex;\r\n        justify-content: space-between;\r\n        align-items: center;\r\n    }\r\n    \r\n    #line-count-result {\r\n        background-color: rgba(255, 255, 255, 0.1);\r\n        padding: 4px 12px;\r\n        border-radius: 12px;\r\n        font-size: 0.9rem;\r\n        font-weight: 400;\r\n    }\r\n\r\n    \/* === Textarea and Line Numbers === *\/\r\n    .textarea-container {\r\n        flex: 1;\r\n        position: relative;\r\n        background-color: #ffffff;\r\n        border: 1.5px solid #EBEBEB;\r\n        border-top: none; \/* Header provides the top border *\/\r\n        border-radius: 0 0 8px 8px;\r\n    }\r\n\r\n    .line-numbers {\r\n        position: absolute;\r\n        left: 0;\r\n        top: 0;\r\n        width: 45px; \/* Slightly wider for better spacing *\/\r\n        height: 100%;\r\n        background-color: #f7f7f7;\r\n        border-right: 1.5px solid #EBEBEB;\r\n        padding: 15px 0;\r\n        font-family: 'DM Sans', sans-serif;\r\n        font-size: 13px;\r\n        color: #6c757d;\r\n        text-align: center;\r\n        line-height: 1.5;\r\n        overflow: hidden;\r\n        user-select: none; \/* Prevent selecting line numbers *\/\r\n    }\r\n\r\n    .code-textarea {\r\n        width: 100%;\r\n        height: 100%;\r\n        border: none;\r\n        outline: none;\r\n        padding: 15px 15px 15px 55px; \/* Adjusted padding for line numbers *\/\r\n        font-family: 'Courier New', monospace;\r\n        font-size: 14px;\r\n        line-height: 1.5;\r\n        background-color: transparent;\r\n        resize: none;\r\n        color: #333;\r\n    }\r\n\r\n    .code-textarea::placeholder {\r\n        color: #adb5bd;\r\n        font-style: italic;\r\n    }\r\n\r\n    \/* === Buttons and Actions === *\/\r\n    .tool-actions-container {\r\n        margin-top: 20px;\r\n        display: flex;\r\n        justify-content: center;\r\n        align-items: center;\r\n        gap: 16px;\r\n    }\r\n\r\n    .copy-btn {\r\n        background-color: rgb(255, 255, 255);\r\n        color: black;\r\n        border: 1px solid #ddd;\r\n        padding: 8px 16px;\r\n        border-radius: 4px;\r\n        cursor: pointer;\r\n        font-size: 14px;\r\n        display: flex;\r\n        align-items: center;\r\n        gap: 8px;\r\n        transition: background-color 0.2s;\r\n        box-shadow: 0 0 10px rgba(0,0,0,0.05);\r\n    }\r\n\r\n    .copy-btn:is(:hover, :focus, :focus-visible) {\r\n        background-color: #f6f6f6 !important;\r\n        color: black;\r\n    }\r\n\r\n    .reset-btn {\r\n        background: none;\r\n        border: none;\r\n        color: black;\r\n        text-decoration: underline;\r\n        font-size: 1rem;\r\n        cursor: pointer;\r\n        padding: 0;\r\n        transition: color 0.2s;\r\n    }\r\n\r\n    .reset-btn:is(:hover, :focus, :focus-visible, :active) {\r\n        background: none;\r\n        color: #545454;\r\n        text-decoration: underline;\r\n    }\r\n    \r\n    \/* === Success Message for Copy Action === *\/\r\n    .success-message {\r\n        position: fixed;\r\n        top: 20px;\r\n        right: 20px;\r\n        background-color: #28a745;\r\n        color: white;\r\n        padding: 12px 20px;\r\n        border-radius: 4px;\r\n        font-size: 14px;\r\n        opacity: 0;\r\n        transform: translateY(-20px); \/* Changed animation direction *\/\r\n        transition: all 0.3s ease;\r\n        z-index: 1000;\r\n        pointer-events: none;\r\n    }\r\n\r\n    .success-message.show {\r\n        opacity: 1;\r\n        transform: translateY(0);\r\n    }\r\n\r\n    \/* === Responsive Design === *\/\r\n    @media (max-width: 768px) {\r\n        .html-viewer-app {\r\n            padding: 30px 15px 0;\r\n        }\r\n\r\n        .input-section {\r\n            height: 350px;\r\n        }\r\n    }\r\n<\/style>\r\n\r\n<div class=\"html-viewer-app\" id=\"line-counter-app\">\r\n\r\n    <!-- The Main Tool Box -->\r\n    <div class=\"input-section\">\r\n        <div class=\"section-header\">\r\n            <span>HTML Line Counter<\/span>\r\n            <span id=\"line-count-result\">Lines: 0<\/span>\r\n        <\/div>\r\n        <div class=\"textarea-container\">\r\n            <div class=\"line-numbers\" id=\"line-numbers-display\">1<\/div>\r\n            <textarea id=\"html-input\" class=\"code-textarea\" placeholder=\"Paste your HTML code here to count the lines...\" spellcheck=\"false\"><\/textarea>\r\n        <\/div>\r\n    <\/div>\r\n\r\n    <!-- Action Buttons -->\r\n    <div class=\"tool-actions-container\">\r\n        <button class=\"copy-btn\" id=\"copy-html-btn\">\r\n            <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\r\n                <rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\"><\/rect>\r\n                <path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"><\/path>\r\n            <\/svg>\r\n            <span>Copy HTML<\/span>\r\n        <\/button>\r\n        <button class=\"reset-btn\" id=\"reset-btn\">Clear Content<\/button>\r\n    <\/div>\r\n\r\n    <!-- Floating Success Message -->\r\n    <div class=\"success-message\" id=\"copy-success-msg\">Copied to clipboard!<\/div>\r\n\r\n<\/div>\r\n\r\n<script>\r\n    document.addEventListener('DOMContentLoaded', () => {\r\n        \/\/ Get all the necessary DOM elements\r\n        const htmlInput = document.getElementById('html-input');\r\n        const lineNumbersDisplay = document.getElementById('line-numbers-display');\r\n        const lineCountResult = document.getElementById('line-count-result');\r\n        const copyBtn = document.getElementById('copy-html-btn');\r\n        const resetBtn = document.getElementById('reset-btn');\r\n        const successMsg = document.getElementById('copy-success-msg');\r\n\r\n        \/\/ Function to update the line count and line numbers display\r\n        const updateLineCount = () => {\r\n            const text = htmlInput.value;\r\n            \/\/ Split by newline characters. If the input is empty, treat it as 0 lines.\r\n            const lines = text.length > 0 ? text.split('\\n') : [];\r\n            const lineCount = lines.length;\r\n\r\n            \/\/ Update the count display in the header\r\n            lineCountResult.textContent = `Lines: ${lineCount}`;\r\n\r\n            \/\/ Generate the numbers for the side bar\r\n            let numbersHTML = '';\r\n            for (let i = 1; i <= lineCount; i++) {\r\n                numbersHTML += i + '\\n';\r\n            }\r\n            \/\/ If empty, show at least '1'\r\n            lineNumbersDisplay.textContent = numbersHTML || '1';\r\n        };\r\n\r\n        \/\/ Function to synchronize the scrolling of textarea and line numbers\r\n        const syncScroll = () => {\r\n            lineNumbersDisplay.scrollTop = htmlInput.scrollTop;\r\n        };\r\n\r\n        \/\/ Function to handle the reset action\r\n        const resetTool = () => {\r\n            htmlInput.value = '';\r\n            \/\/ Manually trigger the update function to reset the UI\r\n            updateLineCount();\r\n        };\r\n\r\n        \/\/ Function to handle copying the content\r\n        const copyContent = () => {\r\n            const content = htmlInput.value;\r\n            if (!content) return; \/\/ Don't copy if there's nothing to copy\r\n\r\n            navigator.clipboard.writeText(content).then(() => {\r\n                \/\/ Show success message\r\n                successMsg.classList.add('show');\r\n                \/\/ Hide it after 2 seconds\r\n                setTimeout(() => {\r\n                    successMsg.classList.remove('show');\r\n                }, 2000);\r\n            }).catch(err => {\r\n                console.error('Failed to copy text: ', err);\r\n            });\r\n        };\r\n\r\n        \/\/ Add event listeners\r\n        htmlInput.addEventListener('input', updateLineCount);\r\n        htmlInput.addEventListener('scroll', syncScroll);\r\n        resetBtn.addEventListener('click', resetTool);\r\n        copyBtn.addEventListener('click', copyContent);\r\n\r\n        \/\/ Initial call to set the default state on page load\r\n        updateLineCount();\r\n    });\r\n<\/script>\r\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[22],"tags":[21],"class_list":["post-8310557","post","type-post","status-publish","format-standard","hentry","category-tools","tag-html-css-tools"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>HTML Line Counter<\/title>\n<meta name=\"description\" content=\"Quickly and accurately count lines in your HTML code with the free Elementor HTML Line Counter. Paste your code and get an instant line count for better organization and debugging.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elementor.com\/tools\/html-line-counter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML Line Counter\" \/>\n<meta property=\"og:description\" content=\"Quickly and accurately count lines in your HTML code with the free Elementor HTML Line Counter. Paste your code and get an instant line count for better organization and debugging.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elementor.com\/tools\/html-line-counter\/\" \/>\n<meta property=\"og:site_name\" content=\"Tools\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-10T08:46:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-10T08:49:45+00:00\" \/>\n<meta name=\"author\" content=\"liz@148.red\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"liz@148.red\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/elementor.com\/tools\/html-line-counter\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/tools\/html-line-counter\/\"},\"author\":{\"name\":\"liz@148.red\",\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\"},\"headline\":\"HTML Line Counter\",\"datePublished\":\"2025-09-10T08:46:43+00:00\",\"dateModified\":\"2025-09-10T08:49:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/elementor.com\/tools\/html-line-counter\/\"},\"wordCount\":5,\"keywords\":[\"Html-Css-tools\"],\"articleSection\":[\"tools\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/elementor.com\/tools\/html-line-counter\/\",\"url\":\"https:\/\/elementor.com\/tools\/html-line-counter\/\",\"name\":\"HTML Line Counter\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/tools\/#website\"},\"datePublished\":\"2025-09-10T08:46:43+00:00\",\"dateModified\":\"2025-09-10T08:49:45+00:00\",\"author\":{\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\"},\"description\":\"Quickly and accurately count lines in your HTML code with the free Elementor HTML Line Counter. Paste your code and get an instant line count for better organization and debugging.\",\"breadcrumb\":{\"@id\":\"https:\/\/elementor.com\/tools\/html-line-counter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/elementor.com\/tools\/html-line-counter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/elementor.com\/tools\/html-line-counter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/elementor.com\/tools\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HTML Line Counter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/elementor.com\/tools\/#website\",\"url\":\"https:\/\/elementor.com\/tools\/\",\"name\":\"Tools\",\"description\":\"Just another Elementor hosted website ;)\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/elementor.com\/tools\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac\",\"name\":\"liz@148.red\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g\",\"caption\":\"liz@148.red\"},\"url\":\"https:\/\/elementor.com\/tools\/author\/liz148-red\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML Line Counter","description":"Quickly and accurately count lines in your HTML code with the free Elementor HTML Line Counter. Paste your code and get an instant line count for better organization and debugging.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elementor.com\/tools\/html-line-counter\/","og_locale":"en_US","og_type":"article","og_title":"HTML Line Counter","og_description":"Quickly and accurately count lines in your HTML code with the free Elementor HTML Line Counter. Paste your code and get an instant line count for better organization and debugging.","og_url":"https:\/\/elementor.com\/tools\/html-line-counter\/","og_site_name":"Tools","article_published_time":"2025-09-10T08:46:43+00:00","article_modified_time":"2025-09-10T08:49:45+00:00","author":"liz@148.red","twitter_card":"summary_large_image","twitter_misc":{"Written by":"liz@148.red","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elementor.com\/tools\/html-line-counter\/#article","isPartOf":{"@id":"https:\/\/elementor.com\/tools\/html-line-counter\/"},"author":{"name":"liz@148.red","@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac"},"headline":"HTML Line Counter","datePublished":"2025-09-10T08:46:43+00:00","dateModified":"2025-09-10T08:49:45+00:00","mainEntityOfPage":{"@id":"https:\/\/elementor.com\/tools\/html-line-counter\/"},"wordCount":5,"keywords":["Html-Css-tools"],"articleSection":["tools"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elementor.com\/tools\/html-line-counter\/","url":"https:\/\/elementor.com\/tools\/html-line-counter\/","name":"HTML Line Counter","isPartOf":{"@id":"https:\/\/elementor.com\/tools\/#website"},"datePublished":"2025-09-10T08:46:43+00:00","dateModified":"2025-09-10T08:49:45+00:00","author":{"@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac"},"description":"Quickly and accurately count lines in your HTML code with the free Elementor HTML Line Counter. Paste your code and get an instant line count for better organization and debugging.","breadcrumb":{"@id":"https:\/\/elementor.com\/tools\/html-line-counter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elementor.com\/tools\/html-line-counter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elementor.com\/tools\/html-line-counter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elementor.com\/tools\/"},{"@type":"ListItem","position":2,"name":"HTML Line Counter"}]},{"@type":"WebSite","@id":"https:\/\/elementor.com\/tools\/#website","url":"https:\/\/elementor.com\/tools\/","name":"Tools","description":"Just another Elementor hosted website ;)","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elementor.com\/tools\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elementor.com\/tools\/#\/schema\/person\/80e8375cb95e6030bc2f897c41c985ac","name":"liz@148.red","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63b900d3310bd1ed40162fb27f016e9920ae66fa5be07be5153344329ef7d9d2?s=96&d=mm&r=g","caption":"liz@148.red"},"url":"https:\/\/elementor.com\/tools\/author\/liz148-red\/"}]}},"_links":{"self":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8310557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/comments?post=8310557"}],"version-history":[{"count":1,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8310557\/revisions"}],"predecessor-version":[{"id":8310559,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/posts\/8310557\/revisions\/8310559"}],"wp:attachment":[{"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/media?parent=8310557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/categories?post=8310557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elementor.com\/tools\/wp-json\/wp\/v2\/tags?post=8310557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}