Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to inline LESS stylesheets?

Tags:

css

less

For example, is it possible to do something like:

<style type="text/less">   #foo {     .bar {        font-weight: bold;     }   } </style> 
like image 388
David Wolever Avatar asked Oct 11 '11 19:10

David Wolever


People also ask

Why is inline CSS a bad idea?

One of the main reasons that inline styling is not a good choice for your application is because it does not support (or it has really poor support) for CSS features. Every application nowadays might have to end up using some selectors such as :hover , :active , :focused , etc.

Why you shouldn't use inline styles?

Inline styles, while they have a purpose, generally are not the best way to maintain your website. They go against every one of the best practices: Inline styles don't separate content from design: Inline styles are exactly the same as embedded font and other clunky design tags that modern developers rail against.

Is inline styling slower?

Yes, inline styles are technically faster than an external stylesheet because you are making one less request on top of the page but using an external stylesheet is much preferred for code maintainability.

What is the limitation of inline styles?

Disadvantages of Inline CSS These styles cannot be reused anywhere else. These styles are tough to be edited because they are not stored at a single place. It is not possible to style pseudo-codes and pseudo-classes with inline CSS. Inline CSS does not provide browser cache advantages.


1 Answers

You actually need to use

<style type="text/less"> 

instead of:

<style type="stylesheet/less"> 

Otherwise it won't work.

Remember to place the <style> element before the <script> element to load less.js.

like image 67
Otto Coster Avatar answered Sep 19 '22 01:09

Otto Coster