Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you find mismatched tags in HTML?

Tags:

html

debugging

I've inherited some rather large static HTML files that need to be fixed up to work in webkit-based browsers, Safari in particular. One of the common bugs I've found that cause rendering differences is missing </div> tags. (Both IE7+ and FF3+ seem to ignore these, or make good guesses as to where to close the DIVs, and render as expected.) I'm used to using vim with HTML syntax highlighting for editing, but end up writing awk scripts to match starting and ending tags.

What is your favorite tool or technique for matching start and end tags in a large HTML file?

UPDATE: I'm currently in a shop that targets HTML 4.01 Strict, not XHTML.

like image 603
system PAUSE Avatar asked Sep 15 '09 15:09

system PAUSE


People also ask

How do I find missing tags in HTML?

You can use the Auto-Format feature (Ctrl+K+D) of Microsoft Visual Studio - it reformats your code so that you can easily see whether there are missing tags. I love this feature, it often comes in handy. Save this answer. Show activity on this post.

How do you check tags in HTML?

Right-click while on your webpage in Google Chrome. Click 'Inspect' You'll see the HTML code in a box at the side or bottom of your page. Use Ctrl + F to find particular tags or elements.

How do I find an extra div?

In the left pane of the code view you can see there <> highlight invalid code button, click this button and you will notice the unclosed div highlighted and then close your unclosed div. Press F5 to refresh the page to see that any other unclosed div are there. You can also validate your page in Dreamweaver too.

How do you check a div in HTML?

Use the tagName property to check if an element is a div, e.g. if (div. tagName === 'DIV') {} . The tagName property returns the tag name of the element on which it was accessed. Note that the property returns tag names of DOM elements in uppercase.


1 Answers

The W3C HTML Validator works fairly well, or if you want something a little simpler then the Tidy FireFox plugin also works.

like image 93
Brandon Avatar answered Oct 12 '22 05:10

Brandon