Less data uri

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Less data-uri()

The Less Data-uri function is uniform resource identifier (URI) schema which is used to inline a resource in web pages. The Node uses mime package to determine the correct mine type, if the mime type is not given.

Parameter:

? url: Inline the url of the file.

? mimetype: MIME type string. (optional)

Let's take an example to demonstrate the usage of Data-uri function in the Less file.

Create a HTML file named "simple.html", having the following data.

HTML file: simple.html

  1. <!DOCTYPE html>  
  2. <head>  
  3. <link rel="stylesheet" href="simple.css" type="text/css" />  
  4. </head>  
  5. <body>  
  6.    <h2>JavaTpoint: A solution of all technology.</h2>  
  7. </body>  
  8. </html>  

Less file: simple.less

  1. body{  

  2.    background: data-uri('image.jpg');  

  3. }   

Put the both file ?simple.html? and ?simple.less? inside the root folder of Node.js

Now, execute the following code: lessc simple.less simple.css

Less data uri function1

Output

Less data uri function2

Less data uri function1