Less (Leaner Style Sheets)
Less là bộ tiền xử lý CSS thêm biến, mixin, lồng nhau và hàm vào CSS, biên dịch sang CSS thuần. Nó từng là nền tảng cho Bootstrap (phiên bản 2-3).
Loại MIME
text/x-less
Loại
Văn bản
Nén
Không mất dữ liệu
Ưu điểm
- + Variables and mixins reduce CSS repetition
- + Can compile in the browser without a build step
- + Simpler syntax than early Sass (no indentation rules)
Nhược điểm
- − Declining ecosystem — Sass is more widely used
- − Native CSS custom properties replace many Less features
- − Fewer functions and features than modern Sass
Khi nào nên dùng .LESS
Sử dụng Less cho các dự án đã dùng nó; cho dự án mới, ưu tiên Sass hoặc CSS gốc với custom properties.
Chi tiết kỹ thuật
Less mở rộng CSS với @biến, định nghĩa .mixin(), lồng nhau và hàm tích hợp (darken, lighten, mix). Nó biên dịch phía máy khách (less.js) hoặc phía máy chủ (lessc qua Node.js).
Lịch sử
Alexis Sellier tạo ra Less vào năm 2009 như giải pháp thay thế đơn giản hơn Sass. Bootstrap 2-3 sử dụng Less, thúc đẩy sự phổ biến rộng rãi. Bootstrap 4 chuyển sang Sass năm 2017.