HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<script id="my-scores" type="application/json">
[
{ "identifier": 226, "score": 123 },
{ "identifier": 225, "score": 185 },
{ "identifier": 224, "score": 147 },
{ "identifier": 223, "score": 189 },
{ "identifier": 222, "score": 227, "svg-score": 208 },
{ "identifier": 221, "score": 139 },
{ "identifier": 220, "score": 162 },
{ "identifier": 219, "score": 162, "svg-score": 158 },
{ "identifier": 218, "score": 192 },
{ "identifier": 217, "score": 125 },
{ "identifier": 216, "score": 247 },
{ "identifier": 215, "score": 165 },
{ "identifier": 214, "score": 245 },
{ "identifier": 213, "score": 180, "svg-score": 158 },
{ "identifier": 212, "score": 197 },
{ "identifier": 211, "score": 273 },
{ "identifier": 210, "score": 138 },
{ "identifier": 209, "score": 278 },
{ "identifier": 208, "score": 260, "svg-score": 175 },
{ "identifier": 207, "score": 132 },
{ "identifier": 206, "score": 289, "svg-score": 167 },
{ "identifier": 205, "score": 205, "svg-score": 144 },
{ "identifier": 204, "score": 185 },
{ "identifier": 203, "score": 321 },
{ "identifier": 202, "score": 202, "svg-score": 200 },
{ "identifier": 201, "score": 179 },
{ "identifier": 200, "score": 122 },
{ "identifier": 199, "score": 233, "svg-score": 222 },
{ "identifier": 198, "score": 179, "svg-score": 172 },
{ "identifier": 197, "score": 303 },
{ "identifier": 196, "score": 175, "svg-score": 168 },
{ "identifier": 195, "score": 408 },
{ "identifier": 194, "score": 214, "svg-score": 195 },
{ "identifier": 193, "score": 240 },
{ "identifier": 192, "score": 145, "svg-score": 129 },
{ "identifier": 191, "score": 180, "svg-score": 170 },
{ "identifier": 190, "score": 172, "svg-score": 139 },
{ "identifier": 189, "score": 161, "rank": 3, "svg-score": 137 },
{ "identifier": 188, "score": 160, "rank": 3 },
{ "identifier": 187, "score": 147 },
{ "identifier": 186, "score": 192, "svg-score": 178 },
{ "identifier": 185, "score": 415, "svg-score": 320 },
{ "identifier": 184, "score": 187 },
{ "identifier": 183, "score": 175 },
{ "identifier": 182, "score": 77, "rank": 3, "svg-score": 72 },
{ "identifier": 181, "score": 89 },
{ "identifier": 180, "score": 77 },
{ "identifier": 179, "score": 106 },
{ "identifier": 178, "score": 185, "rank": 3, "svg-score": 178 },
{ "identifier": 177, "score": 365, "svg-score": 296 },
{ "identifier": 176, "score": 277, "svg-score": 223 },
{ "identifier": 175, "score": 371, "svg-score": 232 },
{ "identifier": 174, "score": 248, "svg-score": 220 },
{ "identifier": 173, "score": 152, "svg-score": 141 },
{ "identifier": 172, "score": 188, "svg-score": 166 },
{ "identifier": 171, "score": 206, "svg-score": 190 },
{ "identifier": 170, "score": 167 },
{ "identifier": 169, "score": 265, "svg-score": 229 },
{ "identifier": 168, "score": 132, "svg-score": 127 },
{ "identifier": 167, "score": 193 },
{ "identifier": 166, "score": 222, "svg-score": 173 },
{ "identifier": 165, "score": 206, "svg-score": 153 },
{ "identifier": 164, "score": 226 },
{ "identifier": 163, "score": 140, "rank": 1, "svg-score": 136 },
{ "identifier": 162, "score": 104, "svg-score": 98 },
{ "identifier": 161, "score": 97, "svg-score": 95 },
{ "identifier": 160, "score": 109 },
{ "identifier": 159, "score": 78 },
{ "identifier": 158, "score": 144, "svg-score": 137 },
{ "identifier": 157, "score": 262, "svg-score": 228 },
{ "identifier": 156, "score": 147, "svg-score": 146 },
{ "identifier": 155, "score": 101 },
{ "identifier": 154, "score": 210, "svg-score": 191 },
{ "identifier": 153, "score": 150, "svg-score": 131 },
{ "identifier": 152, "score": 319, "svg-score": 186 },
{ "identifier": 151, "score": 268, "svg-score": 164 },
{ "identifier": 150, "score": 134, "svg-score": 80 },
{ "identifier": 149, "score": 177, "svg-score": 145 },
{ "identifier": 148, "score": 100 },
{ "identifier": 147, "score": 110 },
{ "identifier": 146, "score": 98, "svg-score": 82 },
{ "identifier": 145, "score": 118, "svg-score": 82 },
{ "identifier": 144, "score": 141, "svg-score": 78 },
{ "identifier": 143, "score": 57 },
{ "identifier": 142, "score": 99 },
{ "identifier": 141, "score": 151, "svg-score": 142 },
{ "identifier": 140, "score": 86 },
{ "identifier": 139, "score": 120 },
{ "identifier": 138, "score": 191 },
{ "identifier": 137, "score": 82 },
{ "identifier": 136, "score": 129 },
{ "identifier": 135, "score": 123 },
{ "identifier": 134, "score": 94 },
{ "identifier": 133, "score": 160 },
{ "identifier": 132, "score": 167 },
{ "identifier": 131, "score": 173 },
{ "identifier": 130, "score": 119 },
{ "identifier": 129, "score": 149 },
{ "identifier": 128, "score": 91 },
{ "identifier": 127, "score": 161 },
{ "identifier": 126, "score": 148 },
{ "identifier": 125, "score": 165 },
{ "identifier": 124, "score": 231 },
{ "identifier": 123, "score": 140 },
{ "identifier": 122, "score": 205 },
{ "identifier": 121, "score": 198 },
{ "identifier": 120, "score": 218 },
{ "identifier": 119, "score": 189 },
{ "identifier": 118, "score": 165 },
{ "identifier": 117, "score": 207 },
{ "identifier": 116, "score": 146 },
{ "identifier": 115, "score": 127 },
{ "identifier": 114, "score": 84 },
{ "identifier": 113, "score": 60 },
{ "identifier": 112, "score": 79 },
{ "identifier": 111, "score": 114 },
{ "identifier": 110, "score": 112, "rank": 3 },
{ "identifier": 109, "score": 77 },
{ "identifier": 108, "score": 291, "rank": 3 },
{ "identifier": 107, "score": 283, "rank": 3 },
{ "identifier": 106, "score": 131 },
{ "identifier": 105, "score": 262 },
{ "identifier": 104, "score": 273 },
{ "identifier": 103, "score": 241 },
{ "identifier": 102, "score": 225 },
{ "identifier": 101, "score": 172 },
{ "identifier": 100, "score": 242 },
{ "identifier": 99, "score": 155, "rank": 2 },
{ "identifier": 98, "score": 167, "rank": 3 },
{ "identifier": 97, "score": 273 },
{ "identifier": 96, "score": 148 },
{ "identifier": 95, "score": 154 },
{ "identifier": 94, "score": 157 },
{ "identifier": 93, "score": 196, "rank": 3 },
{ "identifier": 92, "score": 114 },
{ "identifier": 91, "score": 125 },
{ "identifier": 90, "score": 135 },
{ "identifier": 89, "score": 133 },
{ "identifier": 88, "score": 95 },
{ "identifier": 87, "score": 147 },
{ "identifier": 86, "score": 134 },
{ "identifier": 85, "score": 134 },
{ "identifier": 84, "score": 96, "rank": 2 },
{ "identifier": 83, "score": 142 },
{ "identifier": 82, "score": 134 },
{ "identifier": 81, "score": 181 },
{ "identifier": 80, "score": 210 },
{ "identifier": 79, "score": 280 },
{ "identifier": 78, "score": 277 },
{ "identifier": 77, "score": 192 },
{ "identifier": 76, "score": 249 },
{ "identifier": 75, "score": 281 },
{ "identifier": 74, "score": 315, "rank": 1 },
{ "identifier": 73, "score": 320, "rank": 1 },
{ "identifier": 72, "score": 189 },
{ "identifier": 71, "score": 344 },
{ "identifier": 70, "score": 232 },
{ "identifier": 69, "score": 206, "rank": 3 },
{ "identifier": 68, "score": 145 },
{ "identifier": 67, "score": 113, "rank": 2 },
{ "identifier": 66, "score": 149, "rank": 2 },
{ "identifier": 65, "score": 209 },
{ "identifier": 64, "score": 158 },
{ "identifier": 63, "score": 168 },
{ "identifier": 62, "score": 161 },
{ "identifier": 61, "score": 185 },
{ "identifier": 60, "score": 99 },
{ "identifier": 59, "score": 191 },
{ "identifier": 58, "score": 259 },
{ "identifier": 57, "score": 205 },
{ "identifier": 56, "score": 174, "rank": 3 },
{ "identifier": 55, "score": 156, "isPublished": true },
{ "identifier": 54, "score": 213 },
{ "identifier": 53, "score": 123, "rank": 3 },
{ "identifier": 52, "score": 218 },
{ "identifier": 51, "score": 231 },
{ "identifier": 50, "score": 295 },
{ "identifier": 49, "score": 185 },
{ "identifier": 48, "score": 127 },
{ "identifier": 47, "score": 252 },
{ "identifier": 46, "score": 97 },
{ "identifier": 45, "score": 149 },
{ "identifier": 44, "score": 107 },
{ "identifier": 43, "score": 144 },
{ "identifier": 42, "score": 209 },
{ "identifier": 41, "score": 142 },
{ "identifier": 40, "score": 107, "rank": 2 },
{ "identifier": 39, "score": 129 },
{ "identifier": 38, "score": 113 },
{ "identifier": 37, "score": 112 },
{ "identifier": 36, "score": 110, "rank": 1 },
{ "identifier": 35, "score": 166 },
{ "identifier": 34, "score": 99, "rank": 2 },
{ "identifier": 33, "score": 155 },
{ "identifier": 32, "score": 107 },
{ "identifier": 31, "score": 86 },
{ "identifier": 30, "score": 82 },
{ "identifier": 29, "score": 90, "rank": 1 },
{ "identifier": 28, "score": 131 },
{ "identifier": 27, "score": 118, "rank": 1 },
{ "identifier": 26, "score": 121 },
{ "identifier": 25, "score": 170 },
{ "identifier": 24, "score": 154 },
{ "identifier": 23, "score": 96 },
{ "identifier": 22, "score": 121 },
{ "identifier": 21, "score": 159 },
{ "identifier": 20, "score": 134 },
{ "identifier": 19, "score": 144 },
{ "identifier": 18, "score": 141 },
{ "identifier": 17, "score": 158, "rank": 2 },
{ "identifier": 16, "score": 146 },
{ "identifier": 15, "score": 109 },
{ "identifier": 14, "score": 112 },
{ "identifier": 13, "score": 54 },
{ "identifier": 12, "score": 120, "x-svg-score": 136 },
{ "identifier": 11, "score": 136, "x-svg-score": 161 },
{ "identifier": 10, "score": 190, "x-svg-score": 213 },
{ "identifier": 9, "score": 109, "rank": 1 },
{ "identifier": 8, "score": 159 },
{ "identifier": 7, "score": 115 },
{ "identifier": 6, "score": 123 },
{ "identifier": 5, "score": 119, "x-svg-score": 146 },
{ "identifier": 4, "score": 83, "x-svg-score": 116 },
{ "identifier": 3, "score": 108, "rank": 2 },
{ "identifier": 2, "score": 65 },
{ "identifier": 1, "score": 54 }
]
</script>
<script id="leader-scores" type="application/json">
[
{ "identifier": 226, "score": 106 },
{ "identifier": 225, "score": 164 },
{ "identifier": 224, "score": 141 },
{ "identifier": 223, "score": 152 },
{ "identifier": 222, "score": 181 },
{ "identifier": 221, "score": 128 },
{ "identifier": 220, "score": 136 },
{ "identifier": 219, "score": 161, "svg-score": 158 },
{ "identifier": 218, "score": 164 },
{ "identifier": 217, "score": 119 },
{ "identifier": 216, "score": 192 },
{ "identifier": 215, "score": 148 },
{ "identifier": 214, "score": 187 },
{ "identifier": 213, "score": 168, "svg-score": 158 },
{ "identifier": 212, "score": 179 },
{ "identifier": 211, "score": 224 },
{ "identifier": 210, "score": 135 },
{ "identifier": 209, "score": 240 },
{ "identifier": 208, "score": 203, "svg-score": 175 },
{ "identifier": 207, "score": 129 },
{ "identifier": 206, "score": 234, "svg-score": 163 },
{ "identifier": 205, "score": 195, "svg-score": 144 },
{ "identifier": 204, "score": 165 },
{ "identifier": 203, "score": 269 },
{ "identifier": 202, "score": 182 },
{ "identifier": 201, "score": 151 },
{ "identifier": 200, "score": 98, "svg-score": 98 },
{ "identifier": 199, "score": 197 },
{ "identifier": 198, "score": 167 },
{ "identifier": 197, "score": 209 },
{ "identifier": 196, "score": 170, "svg-score": 159 },
{ "identifier": 195, "score": 283 },
{ "identifier": 194, "score": 186 },
{ "identifier": 193, "score": 214 },
{ "identifier": 192, "score": 140, "svg-score": 129 },
{ "identifier": 191, "score": 157 },
{ "identifier": 190, "score": 166, "svg-score": 139 },
{ "identifier": 189, "score": 161, "svg-score": 137 },
{ "identifier": 188, "score": 158 },
{ "identifier": 187, "score": 131 },
{ "identifier": 186, "score": 158 },
{ "identifier": 185, "score": 318 },
{ "identifier": 184, "score": 177 },
{ "identifier": 183, "score": 153 },
{ "identifier": 182, "score": 77, "svg-score": 72 },
{ "identifier": 181, "score": 89 },
{ "identifier": 180, "score": 77 },
{ "identifier": 179, "score": 94 },
{ "identifier": 178, "score": 185, "svg-score": 178 },
{ "identifier": 177, "score": 281 },
{ "identifier": 176, "score": 234, "svg-score": 213 },
{ "identifier": 175, "score": 283, "svg-score": 211 },
{ "identifier": 174, "score": 211, "svg-score": 207 },
{ "identifier": 173, "score": 141, "svg-score": 130 },
{ "identifier": 172, "score": 143 },
{ "identifier": 171, "score": 163 },
{ "identifier": 170, "score": 157 },
{ "identifier": 169, "score": 244, "svg-score": 214 },
{ "identifier": 168, "score": 121, "svg-score": 120 },
{ "identifier": 167, "score": 177 },
{ "identifier": 166, "score": 213, "svg-score": 173 },
{ "identifier": 165, "score": 163, "svg-score": 148 },
{ "identifier": 164, "score": 210 },
{ "identifier": 163, "score": 140, "svg-score": 136 },
{ "identifier": 162, "score": 101, "svg-score": 98 },
{ "identifier": 161, "score": 90, "svg-score": 90 },
{ "identifier": 160, "score": 109 },
{ "identifier": 159, "score": 76 },
{ "identifier": 158, "score": 133 },
{ "identifier": 157, "score": 208 },
{ "identifier": 156, "score": 121 },
{ "identifier": 155, "score": 101 },
{ "identifier": 154, "score": 166 },
{ "identifier": 153, "score": 150, "svg-score": 127 },
{ "identifier": 152, "score": 234, "svg-score": 186 },
{ "identifier": 151, "score": 196, "svg-score": 164 },
{ "identifier": 150, "score": 85, "svg-score": 80 },
{ "identifier": 149, "score": 148, "svg-score": 145 },
{ "identifier": 148, "score": 100, "svg-score": 81 },
{ "identifier": 147, "score": 109, "svg-score": 104 },
{ "identifier": 146, "score": 96, "svg-score": 82 },
{ "identifier": 145, "score": 82, "svg-score": 82 },
{ "identifier": 144, "score": 93, "svg-score": 78 },
{ "identifier": 143, "score": 57 },
{ "identifier": 142, "score": 99 },
{ "identifier": 141, "score": 113, "svg-score": 113 },
{ "identifier": 140, "score": 84 },
{ "identifier": 139, "score": 97 },
{ "identifier": 138, "score": 151 },
{ "identifier": 137, "score": 82 },
{ "identifier": 136, "score": 122 },
{ "identifier": 135, "score": 99 },
{ "identifier": 134, "score": 93 },
{ "identifier": 133, "score": 160 },
{ "identifier": 132, "score": 153 },
{ "identifier": 131, "score": 163 },
{ "identifier": 130, "score": 119 },
{ "identifier": 129, "score": 140 },
{ "identifier": 128, "score": 91 },
{ "identifier": 127, "score": 127 },
{ "identifier": 126, "score": 148 },
{ "identifier": 125, "score": 162 },
{ "identifier": 124, "score": 207 },
{ "identifier": 123, "score": 132 },
{ "identifier": 122, "score": 199 },
{ "identifier": 121, "score": 155 },
{ "identifier": 120, "score": 218 },
{ "identifier": 119, "score": 143 },
{ "identifier": 118, "score": 146 },
{ "identifier": 117, "score": 152 },
{ "identifier": 116, "score": 146 },
{ "identifier": 115, "score": 126 },
{ "identifier": 114, "score": 84 },
{ "identifier": 113, "score": 60 },
{ "identifier": 112, "score": 79 },
{ "identifier": 111, "score": 114 },
{ "identifier": 110, "score": 112 },
{ "identifier": 109, "score": 71 },
{ "identifier": 108, "score": 287 },
{ "identifier": 107, "score": 281 },
{ "identifier": 106, "score": 131 },
{ "identifier": 105, "score": 262 },
{ "identifier": 104, "score": 201 },
{ "identifier": 103, "score": 235 },
{ "identifier": 102, "score": 200 },
{ "identifier": 101, "score": 153 },
{ "identifier": 100, "score": 241 },
{ "identifier": 99, "score": 154 },
{ "identifier": 98, "score": 167 },
{ "identifier": 97, "score": 219 },
{ "identifier": 96, "score": 139 },
{ "identifier": 95, "score": 145 },
{ "identifier": 94, "score": 153 },
{ "identifier": 93, "score": 195 },
{ "identifier": 92, "score": 108 },
{ "identifier": 91, "score": 125 },
{ "identifier": 90, "score": 126 },
{ "identifier": 89, "score": 126 },
{ "identifier": 88, "score": 84 },
{ "identifier": 87, "score": 133 },
{ "identifier": 86, "score": 121 },
{ "identifier": 85, "score": 125 },
{ "identifier": 84, "score": 96 },
{ "identifier": 83, "score": 130 },
{ "identifier": 82, "score": 128 },
{ "identifier": 81, "score": 114 },
{ "identifier": 80, "score": 156 },
{ "identifier": 79, "score": 216 },
{ "identifier": 78, "score": 248 },
{ "identifier": 77, "score": 181 },
{ "identifier": 76, "score": 160 },
{ "identifier": 75, "score": 272 },
{ "identifier": 74, "score": 315 },
{ "identifier": 73, "score": 320 },
{ "identifier": 72, "score": 186 },
{ "identifier": 71, "score": 344 },
{ "identifier": 70, "score": 211 },
{ "identifier": 69, "score": 206 },
{ "identifier": 68, "score": 140 },
{ "identifier": 67, "score": 112 },
{ "identifier": 66, "score": 149 },
{ "identifier": 65, "score": 204 },
{ "identifier": 64, "score": 146 },
{ "identifier": 63, "score": 152 },
{ "identifier": 62, "score": 161 },
{ "identifier": 61, "score": 184 },
{ "identifier": 60, "score": 99 },
{ "identifier": 59, "score": 147 },
{ "identifier": 58, "score": 220 },
{ "identifier": 57, "score": 187 },
{ "identifier": 56, "score": 171 },
{ "identifier": 55, "score": 136 },
{ "identifier": 54, "score": 201 },
{ "identifier": 53, "score": 123 },
{ "identifier": 52, "score": 159 },
{ "identifier": 51, "score": 198 },
{ "identifier": 50, "score": 272 },
{ "identifier": 49, "score": 165 },
{ "identifier": 48, "score": 125 },
{ "identifier": 47, "score": 191 },
{ "identifier": 46, "score": 95 },
{ "identifier": 45, "score": 140 },
{ "identifier": 44, "score": 98 },
{ "identifier": 43, "score": 112 },
{ "identifier": 42, "score": 164 },
{ "identifier": 41, "score": 142 },
{ "identifier": 40, "score": 107 },
{ "identifier": 39, "score": 125 },
{ "identifier": 38, "score": 100 },
{ "identifier": 37, "score": 108 },
{ "identifier": 36, "score": 110 },
{ "identifier": 35, "score": 138 },
{ "identifier": 34, "score": 99 },
{ "identifier": 33, "score": 130 },
{ "identifier": 32, "score": 104 },
{ "identifier": 31, "score": 85 },
{ "identifier": 30, "score": 82 },
{ "identifier": 29, "score": 90 },
{ "identifier": 28, "score": 131 },
{ "identifier": 27, "score": 118 },
{ "identifier": 26, "score": 107 },
{ "identifier": 25, "score": 153 },
{ "identifier": 24, "score": 114 },
{ "identifier": 23, "score": 90 },
{ "identifier": 22, "score": 89 },
{ "identifier": 21, "score": 137 },
{ "identifier": 20, "score": 126 },
{ "identifier": 19, "score": 116 },
{ "identifier": 18, "score": 141 },
{ "identifier": 17, "score": 158 },
{ "identifier": 16, "score": 139 },
{ "identifier": 15, "score": 104 },
{ "identifier": 14, "score": 104 },
{ "identifier": 13, "score": 54 },
{ "identifier": 12, "score": 100, "x-svg-score": 129 },
{ "identifier": 11, "score": 135, "x-svg-score": 158 },
{ "identifier": 10, "score": 181 },
{ "identifier": 9, "score": 109 },
{ "identifier": 8, "score": 132, "x-svg-score": 164 },
{ "identifier": 7, "score": 115 },
{ "identifier": 6, "score": 104 },
{ "identifier": 5, "score": 115 },
{ "identifier": 4, "score": 83, "x-svg-score": 105 },
{ "identifier": 3, "score": 108 },
{ "identifier": 2, "score": 65 },
{ "identifier": 1, "score": 54 }
]
</script>
<script id="names" type="application/json">
[
{ "identifier": 226, "name": "Bond" },
{ "identifier": 225, "name": "Spark" },
{ "identifier": 224, "name": "Levelled" },
{ "identifier": 223, "name": "UFO" },
{ "identifier": 222, "name": "Rocket" },
{ "identifier": 221, "name": "Entangled" },
{ "identifier": 220, "name": "Building" },
{ "identifier": 219, "name": "CodePen" },
{ "identifier": 218, "name": "3D" },
{ "identifier": 217, "name": "Maze" },
{ "identifier": 216, "name": "Pies" },
{ "identifier": 215, "name": "Staggered checks" },
{ "identifier": 214, "name": "Newspaper" },
{ "identifier": 213, "name": "Boat" },
{ "identifier": 212, "name": "Fibonacci peacock" },
{ "identifier": 211, "name": "CSS Weekly" },
{ "identifier": 210, "name": "Black widow logo" },
{ "identifier": 209, "name": "Iron man" },
{ "identifier": 208, "name": "Hulk fist" },
{ "identifier": 207, "name": "Green Lantern logo" },
{ "identifier": 206, "name": "Punisher" },
{ "identifier": 205, "name": "Magneto's helmet" },
{ "identifier": 204, "name": "Deadpool" },
{ "identifier": 203, "name": "Wolverine" },
{ "identifier": 202, "name": "Steering Wheel" },
{ "identifier": 201, "name": "Triple Zero" },
{ "identifier": 200, "name": "Lantern" },
{ "identifier": 199, "name": "Antenna" },
{ "identifier": 198, "name": "Walls" },
{ "identifier": 197, "name": "Crystal" },
{ "identifier": 196, "name": "Tree" },
{ "identifier": 195, "name": "LookAway" },
{ "identifier": 194, "name": "Fountain" },
{ "identifier": 193, "name": "Galver" },
{ "identifier": 192, "name": "Abstract Firefly" },
{ "identifier": 191, "name": "Modern Fence" },
{ "identifier": 190, "name": "Power Chip" },
{ "identifier": 189, "name": "Triangle Hook" },
{ "identifier": 188, "name": "Icecream Sticks" },
{ "identifier": 187, "name": "Striped Triangle" },
{ "identifier": 186, "name": "Guernsey" },
{ "identifier": 185, "name": "South Korea" },
{ "identifier": 184, "name": "India" },
{ "identifier": 183, "name": "Brazil" },
{ "identifier": 182, "name": "Bahrain" },
{ "identifier": 181, "name": "Iceland" },
{ "identifier": 180, "name": "Kuwait" },
{ "identifier": 179, "name": "Tanzania" },
{ "identifier": 178, "name": "Candy" },
{ "identifier": 177, "name": "Frankenstein" },
{ "identifier": 176, "name": "Castlevania" },
{ "identifier": 175, "name": "Evil Cat" },
{ "identifier": 174, "name": "Witch's Hat" },
{ "identifier": 173, "name": "Hockey Mask" },
{ "identifier": 172, "name": "Crossbones" },
{ "identifier": 171, "name": "Pumpkin" },
{ "identifier": 170, "name": "Party Hat" },
{ "identifier": 169, "name": "Abstract Plate" },
{ "identifier": 168, "name": "Carpet" },
{ "identifier": 167, "name": "React India" },
{ "identifier": 166, "name": "Flow" },
{ "identifier": 165, "name": "Pyramid" },
{ "identifier": 164, "name": "Rangoli" },
{ "identifier": 163, "name": "Missing Piece" },
{ "identifier": 162, "name": "Upwards" },
{ "identifier": 161, "name": "Converge" },
{ "identifier": 160, "name": "Donut", "isPublished": true },
{ "identifier": 159, "name": "Portal" },
{ "identifier": 158, "name": "Clubs" },
{ "identifier": 157, "name": "Monopoly" },
{ "identifier": 156, "name": "Chinese Checkers" },
{ "identifier": 155, "name": "Snakes & Ladders" },
{ "identifier": 154, "name": "Poker Chip" },
{ "identifier": 153, "name": "Checkers" },
{ "identifier": 152, "name": "Rook" },
{ "identifier": 151, "name": "Pawn" },
{ "identifier": 150, "name": "Finger Heart" },
{ "identifier": 149, "name": "Earthworm" },
{ "identifier": 148, "name": "Eight", "isOpen": true },
{ "identifier": 147, "name": "Splash" },
{ "identifier": 146, "name": "Streaks" },
{ "identifier": 145, "name": "Spotlight" },
{ "identifier": 144, "name": "Long Heart" },
{ "identifier": 143, "name": "Simply Circle" },
{ "identifier": 142, "name": "Curtains", "isOpen": true },
{ "identifier": 141, "name": "Third Eye" },
{ "identifier": 140, "name": "Eclipse" },
{ "identifier": 139, "name": "Lamp" },
{ "identifier": 138, "name": "Lotus" },
{ "identifier": 137, "name": "Elbow", "isOpen": true },
{ "identifier": 136, "name": "Alien Eye" },
{ "identifier": 135, "name": "Spikes" },
{ "identifier": 134, "name": "Wig" },
{ "identifier": 133, "name": "Spiral" },
{ "identifier": 132, "name": "Letter S" },
{ "identifier": 131, "name": "Letter W" },
{ "identifier": 130, "name": "Letter O", "isOpen": true },
{ "identifier": 129, "name": "Letter B" },
{ "identifier": 128, "name": "Letter N" },
{ "identifier": 127, "name": "Letter I" },
{ "identifier": 126, "name": "Letter A" },
{ "identifier": 125, "name": "Root Learn" },
{ "identifier": 124, "name": "Space Invaders" },
{ "identifier": 123, "name": "Snake" },
{ "identifier": 122, "name": "Tetris" },
{ "identifier": 121, "name": "Duck Hunt" },
{ "identifier": 120, "name": "Tank", "isOpen": true },
{ "identifier": 119, "name": "Pacman" },
{ "identifier": 118, "name": "Donkey Kong" },
{ "identifier": 117, "name": "Arineo" },
{ "identifier": 116, "name": "Headphones" },
{ "identifier": 115, "name": "Droplet" },
{ "identifier": 114, "name": "Negative Box" },
{ "identifier": 113, "name": "Black Light" },
{ "identifier": 112, "name": "Chevron" },
{ "identifier": 111, "name": "Rain Drops", "isOpen": true },
{ "identifier": 110, "name": "Sunrays" },
{ "identifier": 109, "name": "Curtain" },
{ "identifier": 108, "name": "Clow Card" },
{ "identifier": 107, "name": "Sealing Wand" },
{ "identifier": 106, "name": "Ryuk’s Apple", "isOpen": true },
{ "identifier": 105, "name": "Ryuk" },
{ "identifier": 104, "name": "Amegakure" },
{ "identifier": 103, "name": "Super Saiyan" },
{ "identifier": 102, "name": "One Piece" },
{ "identifier": 101, "name": "Sharingan" },
{ "identifier": 100, "name": "CSSBattle", "isOpen": true },
{ "identifier": 99, "name": "Gift Box" },
{ "identifier": 98, "name": "Candle" },
{ "identifier": 97, "name": "Snowman" },
{ "identifier": 96, "name": "Mandala" },
{ "identifier": 95, "name": "Pokeball" },
{ "identifier": 94, "name": "Ripples" },
{ "identifier": 93, "name": "Great Wall" },
{ "identifier": 92, "name": "Squeeze" },
{ "identifier": 91, "name": "Reflection", "isOpen": true },
{ "identifier": 90, "name": "Eclipse" },
{ "identifier": 89, "name": "Summit" },
{ "identifier": 88, "name": "Tight Corner" },
{ "identifier": 87, "name": "Building Blocks" },
{ "identifier": 86, "name": "Stairway" },
{ "identifier": 85, "name": "Pythagoras" },
{ "identifier": 84, "name": "Junction", "isOpen": true },
{ "identifier": 83, "name": "Supernova" },
{ "identifier": 82, "name": "Diamond Cut" },
{ "identifier": 81, "name": "Odoo" },
{ "identifier": 80, "name": "Piano" },
{ "identifier": 79, "name": "Tambourine" },
{ "identifier": 78, "name": "Ukulele" },
{ "identifier": 77, "name": "Notes" },
{ "identifier": 76, "name": "Beeee" },
{ "identifier": 75, "name": "Hippo" },
{ "identifier": 74, "name": "Danger Noodle" },
{ "identifier": 73, "name": "Happy Tiger", "isOpen": true },
{ "identifier": 72, "name": "Sheep" },
{ "identifier": 71, "name": "Elephant", "isOpen": true },
{ "identifier": 70, "name": "Froggy" },
{ "identifier": 69, "name": "PushOwl", "isOpen": true },
{ "identifier": 68, "name": "Bell" },
{ "identifier": 67, "name": "Video Reel" },
{ "identifier": 66, "name": "Batmicky" },
{ "identifier": 65, "name": "Max Volume" },
{ "identifier": 64, "name": "Door Knob" },
{ "identifier": 63, "name": "Command Key" },
{ "identifier": 62, "name": "Sunset", "isOpen": true },
{ "identifier": 61, "name": "ImprovMX" },
{ "identifier": 60, "name": "Evil Triangles" },
{ "identifier": 59, "name": "Earth" },
{ "identifier": 58, "name": "Rose" },
{ "identifier": 57, "name": "Pillars" },
{ "identifier": 56, "name": "Skull" },
{ "identifier": 55, "name": "Windmill" },
{ "identifier": 54, "name": "Black Lives Matter" },
{ "identifier": 53, "name": "Pastel Logo" },
{ "identifier": 52, "name": "Break the Chain" },
{ "identifier": 51, "name": "Wear a Mask" },
{ "identifier": 50, "name": "Use Hand Sanitizer" },
{ "identifier": 49, "name": "Stay at Home" },
{ "identifier": 48, "name": "Wash Your Hands" },
{ "identifier": 47, "name": "Corona Virus" },
{ "identifier": 46, "name": "Mountains" },
{ "identifier": 45, "name": "Magical Tree" },
{ "identifier": 44, "name": "Stripes" },
{ "identifier": 43, "name": "Wrench" },
{ "identifier": 42, "name": "Baby" },
{ "identifier": 41, "name": "Fox Head" },
{ "identifier": 40, "name": "Letter B" },
{ "identifier": 39, "name": "Sunset" },
{ "identifier": 38, "name": "Not Simply Square" },
{ "identifier": 37, "name": "Tunnel" },
{ "identifier": 36, "name": "Interleaved" },
{ "identifier": 35, "name": "Ice Cream" },
{ "identifier": 34, "name": "Christmas Tree" },
{ "identifier": 33, "name": "Birdie" },
{ "identifier": 32, "name": "Band-aid" },
{ "identifier": 31, "name": "Equals" },
{ "identifier": 30, "name": "Horizon" },
{ "identifier": 29, "name": "Suffocate" },
{ "identifier": 28, "name": "Cups & Balls" },
{ "identifier": 27, "name": "Lock Up" },
{ "identifier": 26, "name": "Smiley" },
{ "identifier": 25, "name": "Blossom" },
{ "identifier": 24, "name": "Switches" },
{ "identifier": 23, "name": "Boxception" },
{ "identifier": 22, "name": "Cloud" },
{ "identifier": 21, "name": "SitePoint Logo" },
{ "identifier": 20, "name": "Ticket" },
{ "identifier": 19, "name": "Cube" },
{ "identifier": 18, "name": "Matrix" },
{ "identifier": 17, "name": "Fidget Spinner" },
{ "identifier": 16, "name": "Eye of the Tiger" },
{ "identifier": 15, "name": "Overlap" },
{ "identifier": 14, "name": "Web Maker Logo" },
{ "identifier": 13, "name": "Totally Triangle" },
{ "identifier": 12, "name": "Wiggly Moustache" },
{ "identifier": 11, "name": "Eye of Sauron" },
{ "identifier": 10, "name": "Cloaked Spirits" },
{ "identifier": 9, "name": "Tesseract" },
{ "identifier": 8, "name": "Forking Crazy" },
{ "identifier": 7, "name": "Leafy Trail", "isPublished": true },
{ "identifier": 6, "name": "Missing Slice" },
{ "identifier": 5, "name": "Acid Rain" },
{ "identifier": 4, "name": "Ups n Downs" },
{ "identifier": 3, "name": "Push Button" },
{ "identifier": 2, "name": "Carrom" },
{ "identifier": 1, "name": "Simply Square", "isPublished": true }
]
</script>
<table>
<thead>
<tr>
<th>target</th>
<th>target name</th>
<th>my score</th>
<th>leader’s score</th>
<th>difference</th>
</tr>
</thead>
<tbody></tbody>
</table>
*, ::before, ::after { box-sizing: border-box }
:root
{
--background-color: #f8f8f8;
background: var(--background-color);
font-family: Source Sans Pro, sans-serif;
font-variant-numeric: lining-nums tabular-nums;
line-height: 0.8;
}
table
{
table-layout: fixed;
border-collapse: collapse;
}
th, td
{
min-width: 3em;
padding: 0.125em 0.5rem;
font-weight: normal;
text-align: right;
position: relative;
}
thead th
{
background: var(--background-color);
xposition: sticky;
top: 0;
}
thead th:nth-of-type(3)
{
padding-right: 0;
text-align: left;
}
thead th:nth-of-type(4)
{
padding-left: 0;
}
td:nth-of-type(2)
{
padding-left: 1.5em;
}
tbody th, td:nth-of-type(4)
{
white-space: nowrap;
}
.medal {
position: absolute;
left: 0;
}
img
{
width: auto;
height: .72em;
margin-left: 0.15em;
vertical-align: top;
left: 0;
}
tr.svg-scores
{
font-size: 0.8em;
}
thead th
{
width: min-content;
}
thead th:nth-of-type(2),
thead th:last-of-type,
tr:not(.svg-scores) td:first-of-type
{
text-align: left;
}
tbody tr:not(.svg-scores) th
{
font: 2em/0.7 Roboto Condensed, Source Sans Pro, sans-serif;
letter-spacing: -0.05em;
font-variant-numeric: tabular-nums;
}
tr.open td:first-of-type::after
{
content: url(https://cssbattle.dev/images/open-book.svg);
position: absolute;
right: 0.5em;
transform-origin: right 12%;
transform: scale(0.3);
}
th[rowspan] ~ td
{
padding-bottom: 0;
}
tr.svg-scores td
{
padding-top: 0;
}
meter
{
width: 12rem;
margin-left: 0.25rem;
background: transparent;
height: 0.75em;
vertical-align: 0%;
}
tr.svg-scores meter
{
height: 0.5em;
}
::-moz-meter-bar {
background: hsl(
calc(120deg - 80deg * var(--leaderScoreSlope)),
100%,
calc(30% + 20% * var(--leaderScoreSlope))
);
background: linear-gradient(
to right,
hsl(
calc(120deg - 80deg * var(--leaderScoreSlope)),
100%,
calc(30% + 20% * var(--leaderScoreSlope))
),
hsl(
calc(120deg - 80deg * var(--myScoreSlope)),
100%,
calc(30% + 20% * var(--myScoreSlope))
)
);
}
a
{
color: currentColor;
text-decoration: none;
}
const showSVGResults = true;
const data = JSON.parse(document.querySelector('#names').textContent);
const myScores = JSON.parse(document.querySelector('#my-scores').textContent);
const leaderScores = JSON.parse(document.querySelector('#leader-scores').textContent);
const score = (char) => 400 * Math.exp(-0.01 * char) + 600;
const medals = ['🥇', '🥈', '🥉'];
let maxDifference = 0;
for (target of myScores)
{
let index = data.findIndex((element) => element.identifier == target.identifier);
if (index == -1)
{
index = data.length;
console.log(index);
}
data[index].myScore = target.score;
data[index].mySVGScore = target['svg-score'];
data[index].myRank = target.rank;
}
for (target of leaderScores)
{
let index = data.findIndex((element) => element.identifier == target.identifier);
if (index == -1)
{
index = data.length;
}
data[index].leaderScore = target.score;
data[index].leaderSVGScore = target['svg-score'];
}
for (target of data)
{
if (target.myScore && target.leaderScore)
{
target.difference = target.myScore - target.leaderScore;
maxDifference = Math.max(maxDifference, target.difference);
}
if (showSVGResults) {
if (target.mySVGScore && target.leaderSVGScore)
{
target.svgDifference = target.mySVGScore - target.leaderSVGScore;
maxDifference = Math.max(maxDifference, target.svgDifference);
}
else if (target.mySVGScore && target.leaderScore)
{
target.svgDifference = target.mySVGScore - target.leaderScore;
maxDifference = Math.max(maxDifference, target.svgDifference);
}
else if (target.myScore && target.leaderSVGScore)
{
target.svgDifference = target.myScore - target.leaderSVGScore;
maxDifference = Math.max(maxDifference, target.svgDifference);
}
}
}
data.sort((a, b) => a.identifier - b.identifier);
const tBody = document.querySelector('table').tBodies[0];
for (target of data)
{
const isSVG = showSVGResults && (target.mySVGScore || target.leaderSVGScore);
const medal = target.myRank && [1, 2, 3].includes(target.myRank) ? medals[target.myRank - 1] : '';
tBody.insertAdjacentHTML('beforeend', `
<tr ${target.isOpen ? 'class="open"' : ''}>
<th ${isSVG ? 'rowspan="2"' : ''}>
<a href="https://cssbattle.dev/play/${target.identifier}" target="_blank">
<span>${target.identifier}</span>
<img src="//cssbattle.dev/targets/${target.identifier}.png" width="400" height="300" alt=""/>
</a>
</th>
<td>
<a href="https://cssbattle.dev/play/${target.identifier}" target="_blank">
${target.name}
</a>
</td>
<td>
${medal ? `<span class="medal">${medal}</span>` : ''}
${target.myScore || ''}
</td>
<td>${target.leaderScore || ''}</td>
<td>${typeof target.difference == 'number' ? `${target.difference} <meter min="0" max="${maxDifference}" value="${target.difference}" optimum="0" high="19.5" low="9.5" style="--myScore: ${score(target.myScore)}; --myScore-1: ${score(target.myScore - 1)}; --leaderScore: ${score(target.leaderScore)}; --difference: ${score(target.myScore) - score(target.leaderScore)}; --myScoreSlope: ${score(target.myScore - 1) - score(target.myScore)}; --leaderScoreSlope: ${score(target.leaderScore - 1) - score(target.leaderScore)}"></meter>` : ''}</td>
</tr>
`);
if (showSVGResults && isSVG)
{
tBody.insertAdjacentHTML('beforeend', `
<tr class="svg-scores">
<th>${target.identifier == '10' ? 'SVG' : 'all'}:</th>
<td>${target.mySVGScore || ''}</td>
<td>${target.leaderSVGScore || ''}</td>
<td>${typeof target.svgDifference == 'number' ? `${target.svgDifference} <meter min="0" max="${maxDifference}" value="${target.svgDifference}" optimum="0" high="19.5" low="9.5"></meter>` : ''}</td>
</tr>
`);
}
}
fetchTarget(data.length + 1);
function fetchTarget(identifier)
{
fetch(`//cssbattle.dev/targets/${identifier}.png`)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error, status = ${response.status}`);
}
return response.blob();
})
.then(blob => {
console.debug(`🧐 ${identifier}`);
tBody.insertAdjacentHTML('beforeend', `
<tr>
<th>
<span>${identifier}</span>
<img src="${URL.createObjectURL(blob)}" alt=""/>
</th>
</tr>
`);
fetchTarget(identifier + 1);
});
}
window.scrollTo({
top: document.body.offsetHeight
});
Also see: Tab Triggers