Google Chrome is a popular web browser that allows users to view the source code of websites. This can be helpful for debugging issues or understanding how a website works. To view the source code in Google Chrome, open the website in the browser and click on the three lines in the top left corner of the window. This will open a new tab with the website’s source code displayed. ..
Whether you’re a web designer debugging your site’s source code or just curious about what a site’s code looks like, you can view the HTML source right in Google Chrome. There are two ways to view the HTML source: View Source and Inspect using Developer Tools.
View Source Using View Page Source
Fire up Chrome and jump to the webpage you want to view the HTML source code. Right-click the page and click on “View Page Source,” or press Ctrl + U, to see the page’s source in a new tab.
A new tab opens along with all the HTML for the webpage, completely expanded and unformatted.
If you’re looking for a specific element or part in the HTML source, using View Source is tedious and cumbersome, especially if the page uses a lot of JavaScript and CSS.
Inspect Source Using Developer Tools
This method uses the Developer Tools pane in Chrome and is a much cleaner approach to view the source code. HTML is easier to read here thanks to the additional formatting and the ability to collapse elements you aren’t interested in seeing.
Open Chrome and head to the page you want to inspect; then press Ctrl + Shift + i. A docked pane will open alongside the webpage you’re viewing.
Click on the little gray arrow next to an element to expand it even further.
If you don’t want to see the full page’s code by default, but instead inspect a specific element in the HTML, right-click that space on the page, then click “Inspect.”
When the pane opens this time, it goes directly to the portion of code that contains that element you clicked.
If you want to change the dock position, you can move it to the bottom, left, right, or even undock it into a separate window. Click the menu icon (three dots), then choose either undock into a separate window, dock to the left, dock to the bottom, or dock to the right, respectively.
That’s all there is to it. When you finish looking at the code, either close the View Source tab or click the ‘X’ in the Developer Tools pane to return to your webpage.