A couple of days ago, I was having a little CSS trouble. In the end, it turned out that I had set a property of an element "above" in the document tree, and the problematic element was inheriting that property.
It struck me that it would be easier to work through this kind of CSS problem with some kind of simple tool to show how a page was put together. If I could see all the tags on the page in a nested format, with parent and child relationships obvious, and without all the text getting in the way, my life would be easier.
So, I put together this tool. In simple terms, it will fetch a page from a web server and output the tags within the page in a nested list. The JavaScript side of it will also highlight children of an element when you hover over it.
Classes and ids attributes are highlighted, as are tag names. Class and ID names, though, must be enclosed in quotation marks to be highlighted. Text, closing tags and line breaks are not shown. Though I can understand some people may find it useful to see text, I found it made the tree too large to be usable.
I've used it a few times, and am quickly finding it saves quite a lot of time solving simple CSS problems or conflicts. Which is exactly what it was supposed to do. Enjoy!
Highlighting Issues
When writing the tool, I came across a fairly unusual problem. I wanted, when the mouse was over an element, to highlight its children. However, this cannot be done with CSS (at least, I couldn't think of a way to make it work).
The problem with the CSS was that whenever you hover over an element, you are also hovering over its parents. So they, and their children, are highlighted - meaning everything is highlighted. For this reason, the highlighting of elements uses JavaScript.
How to Use
The page structure tool is written to accept a URL either by GET or POST. You can therefore use it one of two ways.
First, you can use the tool by visiting the URL below, replacing "##url##" with the address of the page you want to view:
http://www.addedbytes.com/view_structure.php?url=##url##
Alternatively, you can use the following form to submit an address to the page:
Bookmarklet
To make life a little easier, I've coded a quick JavaScript bookmarklet for you to use, that, when activated, will automatically submit the URL of the page you are viewing to the tool. Simply copy or drag the link below to your links bar, your favourites folder or anywhere else you wish:
Notes
- This tool works best with valid code, especially XHTML.
- A certain amount of basic code improvement is done before processing (for example all empty tags are automatically closed).
- Sites with non-empty tags that aren't closed properly may not show up correctly.
- Sites with large amounts of nested code should still show up, but it may be difficult to view the output.
Example
If you want to see an example of the output of this tool, you can view the structure for AddedBytes.com.

26 Comments
very cool and nicely done !
#1, gb, France, 18 October 2004. Reply to this.
Hey good idea. It's an interesting alternative to Dom inspector and web dev tools for firefox. I tried it out on a few sites and was quite impressed. Thanks!
#2, Jim Amos, United States, 21 October 2004. Reply to this.
Thanks Jim and gb.
I have a few ideas for improvements and expansions to it, so will be working on it over time. If you've any ideas for improvements or additions, though, please let me know!
#3, Dave Child, United Kingdom, 22 October 2004. Reply to this.
Wow, this works great! I will definitely be utilizing this tool next time my code goes wacky on me. Thanks!
#4, CJ, United States, 22 February 2005. Reply to this.
Is there an error in the script? This used to work, but now it does not place a border around the elements.
This tool is great for instructional purposes.
#5, John Davey, United States, 27 May 2005. Reply to this.
Nicely spotted, John, thankyou.
It appears that in a recent edit I deleted the script tag that adds the JavaScript functionality to that page. Oops! Fixed now though :)
#6, Dave Child, United Kingdom, 27 May 2005. Reply to this.
Thank God for my love of JD. It directed me to this site and, in turn, to this terrific resource.
TO think I'd been relying on Dreamweaver's poorly rendered views all this time.
#7, Paul Noone, Australia, 15 June 2005. Reply to this.
A very useful addition is to be able to export the page to PDF or otherwise print it with the elements highlighted in a hierarchy.
#8, Paul Noone, Australia, 15 June 2005. Reply to this.
check out 'Xyle scope' from http://www.culturedcode.com/
very incredible for debugging CSS. (not to belittle what you have done, which is great!)
#9, bughouse, United States, 2 August 2005. Reply to this.
great tool! i can see now how badly written my page is and fix it ;)
#10, washy, Germany, 5 August 2005. Reply to this.
Did you do that with PHP's XML reading tools, I really need help with them... Probably help if I knew how to use XML...
#11, Matt, United Kingdom, 16 August 2005. Reply to this.
Dear Friend,
The Idea is great as well as the implementation no doubt about. But I think there are some bugs.
I face some problem with the code. I checked a webpage. http://www.herbalbd.com/suman/signup.html
and the result doesn't show me the </title> and </head> tag.Where is the problem?
Coolsaint
#12, Coolsaint, Hong Kong, 21 September 2005. Reply to this.
Hello,
I came across your site while testing a content filter on my PC... glad I tried a search for "Jack Daniles"... :) You have a very nice site, the "Live Search" thing is absolutely killer as well as this dom inspector you have written. Very nicely done!
Jim S.
Jacksonville, FL
jimsummer@tentonweb.com
#13, Jacksonville Web Design, United States, 15 October 2005. Reply to this.
Excellent stuff. Would be even more excellent if I could use it on my local pages!
#14, Captain Spaulding, United Kingdom, 7 December 2005. Reply to this.
hi! this is a great tool! :)
#15, mabelle, Philippines, 13 December 2005. Reply to this.
Wonderful tool! I'd like to mention that I've been using a very similar tool in the form of a firefox extension that has been invaluable in troubleshooting code. It is called "View Rendered Source" and along with the Web Developer Toolbar makes coding alot less painful :)
https://addons.mozilla.org/extensions/moreinfo.php?id=655&application=firefox
#16, Kamil, United States, 20 January 2006. Reply to this.
Any chance you're gonna give us the source?
#17, C-T-S, United States, 12 March 2006. Reply to this.
hey jack , this is really cool . it would be of gr8 help if u could give the source...
#18, Choks ,Infy , India, India, 12 July 2006. Reply to this.
Firefox already has an excellent extension to do this, and more
It's called the "View Formatted Source" extension
#19, Markie1006, United States, 18 July 2006. Reply to this.
Nice and helpful tool. I have already checked some of my sites just to see how it work.
#20, hrvoje461, Croatia, 9 August 2006. Reply to this.
This is so elegant! Congratulations not just on the functionality, but on the design of the tool.
#21, Ron Weihs, Canada, Unknown, 30 November 2006. Reply to this.
I now love Jack even more. This is brilliant. Well done!!!!
#22, Al Kendall, Australia, 14 February 2007. Reply to this.
damn! I Love addedbytes! this rocks
#23, sing1ejack, Unknown, 29 March 2007. Reply to this.
Hi great tool! Is there anyway to make the result "downloadable"?
Thanks!
#24, Chad, Australia, 16 August 2007. Reply to this.
This is cool, But consider some pages that the source code might be to long to preview. Because I tried viw this link, http://docs.jquery.com/Tutorials and it almost crash my firefox. Why can't you make it collapsible....
Thanks.
How can I get the script?
#25, Joberror, Unknown, 19 August 2008. Reply to this.
Nice. I needed a replacement for the Firefox extension mentioned in previous comments as it doesn't work with Firefox 3.x. The 3.x version is no longer free.
I see you have not replied to the various comments requesting the source code. I too would love to get a copy of the source but if you don't want to post it that is understandable.
#26, Christian T, United States, 25 September 2008. Reply to this.