How To View the HTML Source in Safari

Want to see how a webpage was built? Try viewing its source code.

HTML code for building a web form
HTML code for building a web form. Image courtesy Gary Conner / Photolibrary / Getty Images

Viewing the HTML source of a web page is one of the easiest (and yet most effective) ways to learn HTML, especially for newer web professionals who are just getting started in the industry. If you see something on a website, and want to know how it was done, view the source code for that site. If you just like the layout of a website, viewing the source to see how that layout was achieved will help you learn and improve your own work.

Over the years, I (along with many other web designers and developers) have learned quite a lot of HTML simply by viewing the source of web pages that I saw. It’s a great way for beginners to learn HTML and for seasoned web professionals to see how new techniques may have been applied to a site.

Remember that source files can be very complicated. Along with the HTML markup for a page, there will probably be a lot of CSS and script files that are used to create that site's look and functionality, so don’t get frustrated if you can’t figure out what’s going on immediately. Viewing the HTML source is just the first step. After that you can use tools like Chris Pederick’s Web Developer extension to look at the CSS and scripts as well as inspect specific elements of the HTML.

If you are using the Safari browser, here is how you can view a page's source code to see how it was created.

Here's How:

  1. Open Safari
  1. Navigate to the web page you would like to examine
  2. Click on the “Develop” menu in the top menubar
  3. If the Develop menu is not visible, go into Preferences in the Advanced section and select “Show Develop menu in menu bar.”
  4. Click on “Show Page Source”
    This will open a text window with the HTML source of the page you’re looking at.


    1. On most web pages you can also view the source by right-clicking on the page (not on an image) and choosing “Show Page Source.” This will only display if the Develop menu is enabled in Preferences.
    2. Safari also has a keyboard shortcut for viewing the HTML source — hold down the command and option keys and hit u — Cmd-Opt-U.


    Is Viewing Source Code Legal?

    Over the years, I have had many new web designers question whether it is acceptable to view a site's source code and use it in their education and work. While copying a site's code wholesale and passing it off as your own on a site is certainly not acceptable, using that code as a springboard to learn from is actually how many advancements are made in this industry. In fact, you would be hard pressed to find a working web professional today who has not learned something by viewing a site's source!

    In the end, web professionals learn from each other and often improve upon the work that they see and are inspired by, so do not hesitate to view a site's source code and use it as a learning tool.