Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is less interpreted by the browser like CSS?

Tags:

html

css

less

There's an example here in which there is a stylesheet of type text/less that is interpreted by google chrome, but appears to have nothing but less syntax in it.

<link rel="stylesheet" href="responsive.less" type="text/less" media="screen" />
like image 713
leeand00 Avatar asked Dec 26 '13 18:12

leeand00


People also ask

How does a browser interpret CSS?

The browser parses the HTML and creates a DOM from it. Next, it parses the CSS. Since the only rule available in the CSS has a span selector, the browser sorts the CSS very quickly! It applies that rule to each one of the three <span> s, then paints the final visual representation to the screen.

Does LESS compile to CSS?

Less (sometimes stylized as LESS) is one of the dynamic style sheet languages that can be compiled into Cascading Style Sheets (CSS), or can run on the server-side and client-side.

Is CSS compiled or interpreted?

css is a style specification defined by w3c consorcium. This style code is interpreted by browsers.So this is not a compiler nor interpreter it is standard.

Is the browser an interpreter?

The code we humans write cannot be read by computers – it must be translated into machine code. Compilers and interpreters do that, and the browser is an interpreter!


3 Answers

No, no browsers interprets LESS directly. The page must have contained less.js, which is a JavaScript implementation of a LESS compiler.

like image 21
Lie Ryan Avatar answered Sep 23 '22 23:09

Lie Ryan


LESS is a dynamic stylesheet compiled by less.js (or in the example given, less-1.1.3.min.js), producing normal CSS once complete. The browser doesn't understand the LESS file itself.

LESS can also be used server-side, as described on the LESS website.

$ npm install -g less
like image 45
Brian S Avatar answered Sep 23 '22 23:09

Brian S


The example also calls <script src="../../js/less-1.1.3.min.js" type="text/javascript"></script>

Here less-1.1.3.min.js compiles the less from responsive.less to css and return it back to the browser. Also see: http://lesscss.org/#usage

See below you will find the client side compiled CSS between <style id="less:examples-responsive-responsive" type="text/css" media="screen">:

enter image description here

like image 196
Bass Jobsen Avatar answered Sep 24 '22 23:09

Bass Jobsen