How to View HTML Source in Safari

If you want to see how a webpage was built, try viewing its source code.

Viewing the HTML source of a web page is one of the easiest (and 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, many web designers and developers have learned quite a lot of HTML simply by viewing the source of web pages they see. 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.

How to View the HTML Source

A webpage's source code as displayed in Safari on a Macintosh computer.
  1. Open Safari.

  2. Navigate to the web page you would like to examine.

  3. Click on the Develop menu in the top menu bar.

    If the Develop menu is not visible, go into Preferences in the Advanced section and select Show Develop menu in menu bar.

  4. Click Show Page Source. This will open a text window with the HTML source of the page you’re looking at.

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.

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?

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 don't hesitate to view a site's source code and use it as a learning tool.