diff --git a/mode/stylus/stylus.js b/mode/stylus/stylus.js
index b83be16f42b617f366828e9c9d51234216665f14..a9f50c05d1f1e63d60dff3aaa3196625f82a7ba0 100644
--- a/mode/stylus/stylus.js
+++ b/mode/stylus/stylus.js
@@ -76,7 +76,7 @@
       if (ch == "#") {
         stream.next();
         // Hex color
-        if (stream.match(/^[0-9a-f]{6}|[0-9a-f]{3}/i)) {
+        if (stream.match(/^[0-9a-f]{3}([0-9a-f]([0-9a-f]{2}){0,2})?\b/i)) {
           return ["atom", "atom"];
         }
         // ID selector