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 they achieved it, view the source code for that site. Safari provides a way to see source code on Mac computers.

Source Code Advantages

Viewing the source to see how a web designer achieved a layout will help you learn and improve your work. Over the years, many web designers and developers have learned quite a lot of HTML by merely viewing the source of web pages they see. It's an excellent way for beginners to learn HTML and for seasoned web professionals to see how others used new techniques.

Remember that source files can be very complicated. Along with the HTML markup for a page, there will probably be significant CSS and script files 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.

View Source Code in Safari

Here's how to show source code in Safari


  1. Open Safari.

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

  3. Select 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. Select the Show Page Source option to open a text window with the HTML source of the page.

    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. You must enable the Develop menu in Preferences for the option to appear.

    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 website is certainly not acceptable, using that code as a springboard to learn from is actually how many people make advancements in this industry. You would be hard-pressed to find a working web professional today who has not discovered something by viewing a site's source!

    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.