Question bank › Stack
Dsa Stack Hard

HTML Tag Validator

You are given a string representing HTML content. Your task is to validate whether the HTML tags are correctly nested and closed. Tags are represented by '<tag>' for opening and '</tag>' for closing. Write a program that reads the HTML string and prints 'VALID' if the tags are correctly nested and 'INVALID' otherwise. Input format: - A single line containing the HTML string (e.g., '<div><span></span></div>'). Output format: - A single line containing either 'VALID' or 'INVALID'. Example: Input: <div><span></span></div> Output: VALID

Key concepts

stackhtmlvalidation

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.