diff --git a/src/common/text/elements/code.js b/src/common/text/elements/code.js
index 5056bd137d..df81b715c2 100644
--- a/src/common/text/elements/code.js
+++ b/src/common/text/elements/code.js
@@ -271,6 +271,20 @@ const elements = [
 		}
 	},
 
+	// nan
+	(code, i, source) => {
+		const prev = source[i - 1];
+		if (prev && /[a-zA-Z]/.test(prev)) return null;
+		if (code.substr(0, 3) == 'NaN') {
+			return {
+				html: `<span class="nan">NaN</span>`,
+				next: 3
+			};
+		} else {
+			return null;
+		}
+	},
+
 	// keyword
 	(code, i, source) => {
 		const prev = source[i - 1];
diff --git a/src/web/app/base.styl b/src/web/app/base.styl
index e753a78d50..0e5eeba971 100644
--- a/src/web/app/base.styl
+++ b/src/web/app/base.styl
@@ -137,6 +137,7 @@ pre
 			color #42b983
 
 		.number
+		.nan
 			color #ae81ff
 
 		.var:not(.keyword)