This article shows how to view HTML source code in Safari.
View Source Code in Safari
Showing source code in Safari is easy:
- Open Safari.
- Navigate to the web page you would like to examine.
- Select the Develop menu in the top menu bar. Select the Show Page Source option to open a text window with the HTML source of the page.Alternatively, press Option+Command+U on your keyboard.
- If the Develop menu is not visible, go into Preferences in the Advanced section and select Show Develop menu in menu bar.
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.)
Advantages of Viewing Source Code
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.
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.