How a web page reaches you
Read a URL
Break a web address into its scheme, host, path, query, and fragment so links and resources make sense later in the course.
A URL identifies a resource on the Web.
Consider this one:
https://example.com/guides/html/?format=short#links
It has several parts:
httpsis the schemeexample.comis the host/guides/html/is the pathformat=shortis the query stringlinksis the fragment
The scheme tells the browser which protocol to use. For websites, that is normally HTTPS.
The host identifies the server. The path identifies a resource on that server. A query string passes extra information, while the fragment points to a location inside the document.
There is one important detail: the browser does not send the fragment in the HTTP request. It uses the fragment after the page arrives, usually to scroll to an element with a matching id.
You will use URLs in links, images, stylesheets, scripts, audio, video, and forms. Understanding their parts now will make all of those elements easier to use.
Be careful with slashes in paths. A path that starts with / begins at the site root. A path without that leading slash is relative to the current document. We cover that difference in a later lesson, but the URL parts are the same either way.
Take the URL in your address bar and identify its scheme, host, and path. If it has a ? or #, identify the query and fragment too. Write the parts on paper once. After a few pages, reading URLs becomes automatic.
Ports appear after the host when a server listens on something other than the default (https://localhost:3000/ is a common local example). Usernames and passwords can appear before the host in some URLs, but you should not put secrets in links on public pages.
Lesson completed