Lines (HTML) is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Lines (HTML)
API ID: CountLineHtmlLanguages: Web
Targets: Architectures, Files, Project
Number of all HTML lines.
Counts every line of an HTML file that isn't inside an embedded sub-language block, including the tag lines that open and close those blocks (such as <script>/</script>).
For example:
<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
<!-- Greeting script: tracks visits and confirms with the user -->
<script>
// Number of times the page has greeted someone
var greetingCount = 0;
function greetUser(name) {
greetingCount++;
return "Hello, " + name + "!";
}
let message = greetUser("Ada");
console.log(message);
if (greetingCount > 0) {
confirm(message);
}
</script>
</head>
<body>
<h1>Welcome to the site</h1>
<p>Have a look around.</p>
</body>
</html>
sample.html is 28 lines total. The <script> block's contents (lines 8-21) are JavaScript, but the <script> (7) and </script> (22) tag lines themselves still count as HTML, along with the rest of the page (1-6, 23-28), giving CountLineHtml = 14.
See Lines (JavaScript) for the embedded script's contents, and Blank Lines (HTML)/Comment Lines (HTML) for the HTML breakdown. See Lines for the language-independent total across the whole file.
Targets By Language:- Web: Project, File
- This metric can be disabled from "Project Configuration/Metrics/Lines and Statements" with the "Show line count metrics" option.
- This metric can be enabled from "Project Configuration/Metrics/Lines and Statements" with the "Breakdown counts by web language" option.