Using LESS For Better HTML
Using LESS For Better HTML
Introduction to LESS
Tools and usage
Features in detail
Enabling leaner HTML
Outline
Based on CSS
Compiles to CSS
What is LESS?
No standards
Pitfalls
Bootstrap
Rails
Tapestry
ASP.NET
Node.js
PHP
Django
Play
Anything!
Integration
with
LESSHAT
Lots of Love for LESS
LESS Elements
Bootstrap!
Extras: Mixin
Libraries
Alternate implementations
Usage:
Integrated
Usage: Tools
Cross-platform
SASS
LESS
JS
Coffeescript
Minify
LESS 1.5!
Tools: Koala
MAC only
SASS
LESS
JS
Coffeescript
Tools: CodeKit
Crossplatform
LESS only
Issues with
LESS > 1.3?
Otherwise,
great
Tools: SimpLESS
Lots more
Tools
Usage: InBrowser
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<style type="text/less">
@h1color: red;
body > h1 { color: @h1color; }
</style>
<script type="text/javascript"
src=https://cdnjs.cloudflare.com/ajax/libs/less.js/1.7.4/less.min.js">
</script>
</head>
<body><h1>Hello, LESS</h1></body>
</html>
Usage: InBrowser
LANGUAGE
DETAILS
Superset of CSS
Valid CSS should be valid LESS
Imperfect?
Basic Structure
CSS-style comments
Comments
My only gripe!
Variables
Variable
Interpolation
Variable Scope
Nesting
Nesting
Nesting
Mixins
Mixins
Mixins
Namespaces
Pattern matching
Guards
iscolor
isnumber
isstring
iskeyword
isurl
ispixel
ispercentage
isem
Isunit
Guards
Imports
:extend
:extend
Operations
Math:
Functions
LEAN HTML
Philosophical change:
Include appropriate HTML
Think in terms of components
Aligns with recent development:
Angular, React, etc..
Avoid including styling information
Solution?
CSS Antipatterns
CSS Antipatterns
No performance benefit
Maintainability
Rethink your
HTML
SASS
Stylus
Syntax different than CSS
Plain-old CSS
Alternatives to
LESS
Questions? Comments?
Editor: kzantow.github.io/fiddle-less
less2css.org
Thanks!
Try it!