Computernerd
Computernerd

Reputation: 7782

Why can i run HTML in the browser without creating a HTML file

I was suprised when I typed the following into the address bar of the browser

data:text,<h1>Whydoesthiswork??</h1>

that it actually worked and HTML output was produced

enter image description here

I dont understand how can this work , isnt the address bar suppose to convert the sitename into a IP address through the lookup on a DNS. I dont think the job of the address bar is to interpret HTML code.

I am confused now

note: I am using Firefox browser.

Upvotes: 0

Views: 97

Answers (2)

tgogos
tgogos

Reputation: 25220

Take a look at this: data URIs (from the Mozilla Developer Network.)

data URIs, defined by RFC 2397, allow content creators to embed small files inline in documents.

The data URIs have the following syntax:

data:[<mediatype>][;base64],<data>

Upvotes: 2

Jeremy J Starcher
Jeremy J Starcher

Reputation: 23863

A URI/URL is made of several pieces. In this context, the protocol is the most important, and appears as protocol:restOfTheUri. Common examples of protocols are:

  • http
  • https
  • data
  • ftp
  • file

These are all protocols.

When the browser finds the data protocol, it knows what comes next is all that is needed. There is no need for a network connection or look up.

This is the point of the data: protocol.

Upvotes: 3

Related Questions