Use Safari 5′s Web Inspector – a gift for web developers


Use Safari 5′s Web Inspector – a gift for web developers
Mac Tip #444, 07 July 2010

If you develop websites for a living you may be familiar with the Firefox extension called Firebug. If you’re not, you should install it immediately. But Safari has a similar function built right in. You just need to know where to find it. Here’s how. Read the instructions further down the page or watch the video for a quick start.

httpv://www.youtube.com/watch?v=BUQaqn6DM4k

Please subscribe to the MacTips channel. Or just visit this video on YouTube, leave comments and rate it, as that helps spread the word about the MacTips.

The Web Inspector

If you’re a web developer trying to analyse or troubleshoot a web page you’ll be familiar with looking at the HTML source and the CSS stylesheet to figure out how things fit together.

But sometimes it’s a mystery as to exactly why that heading is pushed down too low, or that text is black even though you set it to green. And finding all the right bits of HTML and CSS and putting them together can be very hard work.

That’s where the Web Inspector can save you time and stress: Control (⌃) click on the errant text and choose Inspect Element from the contextual menu. A window pane opens up and shows you exactly the correct part of the HTML coding and the CSS rules that are being applied.

Turn on the Develop menu.

Turn on the Develop menu.

Turn on the Develop menu

The first step is to turn on the Develop menu:

  1. Go to Safari Preferences.
  2. Click on the Advanced tab.
  3. Check the box beside Show Develop menu in menu bar. A new Safari menu item appears, labelled Develop.
  4. Close the Preferences window.

The Develop menu offers a lot

The Develop menu provides easy options for things such as opening a page with another browser, disabling images or styles, and debugging Javascript. But you can now also Inspect page elements.

Inspect page elements.

Inspect page elements.

Inspect an Element

Control (⌃) click on any item on the page to bring up a contextual menu.

Choose Inspect Element. The bottom part of the Safari window slides up to reveal 2 additional panes.

The left pane displays the HTML for the page, with the element you clicked on selected and highlighted.

The right pane displays CSS rules that apply to your selected element.

Hover over different parts of the HTML to see them highlighted in the main part of the window.

Double click an item in the Web Inspector pane and you can edit it. Make changes and see them reflected in the main part of the window.

Note: you’re not actually editing the live website. Any changes you make are being applied only to what you see on your own screen, and so are useful for testing purposes. To actually edit the site you should use your usual methods.

The Web Inspector window

The Web Inspector pane.

The Web Inspector pane.

I could write several more Tips about the Web Inspector pane alone.

If you prefer to see the Web Inspector as a separate window, rather than just a pane in the main window, click the Undock into separate window icon at bottom left of the window (shown enlarged in the screenshot). It looks like one box emerging from another.

Web Inspector Toolbar.

Web Inspector Toolbar.

To see a list of errors and warnings, click the Console button (beside the Undock button). The Web Inspector pane divides so the lower part can display any errors.

A powerful tool for web developers

Safari’s Web Inspector is a powerful tool for web developers, and for anyone interested in seeing what’s really going on behind a web page.

This Tip has really only highlighted its existence. Explore it more thoroughly to get the most use out of it. I may write more about the Web Inspector at my KnowIT blog. I have already written there about using Firebug in a similar way in Firefox: Burn through web development with Firebug.

Tell us in the Comments at the website your experiences with Safari’s Web Inspector.

Related posts

[wpzon keywords="pressure cooker" sindex="PCHardware" snode="1232597011" sort="salesrank" listing="8"]

4 Comments

  1. Lisa said:

    Hi there! Came across your YouTube video for Safari 5, which I had just figured out and then I installed Safari 6, and web inspector is indecipherable to me!

    Any help with figuring out how to do the above, but on Safari 6 now?

  2. Mike said:

    I installed web inspector but now I want to uninstall it (HOW?) Its not your typical open preferences and uninstall it from the extension tab.. I’m running it on a Mac Book Pro.

    • Miraz Jordan said:

      Mike, you don’t install and uninstall Web Inspector as you would, say, an adblocker extension. It’s simply a menu item like Open or Save.

      I don’t have an appropriate version of Safari available at this moment, but if you have the Web Inspector open and no longer need it, for example, close it by clicking the small x in the top left corner (I think).

      If it’s not open and you don’t wish to use it then don’t use it, just as you probably seldom visit the Open command in Safari’s File menu.

      Or is there something else going on that would help me understand what your question is about?

      Cheers,

      Miraz

  3. Miraz Jordan said:

    A reader let me know by email: “I followed along using Safari on a Windows 7 PC and it seems to be all the same functions using the same buttons and panes.”

Comments are closed.

Top