if ('paintWorklet' in CSS) {
    // load this CodePen's JS file as the paint worklet
  } else {

<header class="placeholder"></header>
<div class="content-wrapper">
    <h1>Awesome Mockup</h1>
    <p>This uses placeholder boxes created with the CSS Paint API. Neat! You can resize them by dragging their bottom right corners.</p>
    <div class="row">
      <div class="placeholder"></div>
      <div class="placeholder"></div>
      <div class="placeholder"></div>
    <p>That's all. Thanks!</p>
    <div class="placeholder"></div>

<div class="warning">
  <i class="fas fa-exclamation-triangle"></i><br>
  This Houdini demo requires the <strong>CSS Paint API</strong>.<br>
  Use <strong>Chrome</strong>.<br>
  Also make sure you're serving over <strong>https</strong> or <strong>localhost</strong>.
*, *::before, *::after {
  box-sizing: border-box;

body {
  margin: 20px;
  color: #666;
  background-color: #eee;
  font: 1rem/1.25 'Mukta Mahee', sans-serif;

.placeholder {
  background-image: paint(placeholder-box);

  background-color: #fff;
  max-width: 100%;
  border: 2px solid #666;
  overflow: auto;
  resize: both;

header {
  width: 600px;
  height: 100px;
  margin: 0 auto;

.content-wrapper {
  display: flex;
  width: 600px;
  margin: 40px auto 0;
  font-size: 1.25rem;
  line-height: 1;

main {
  width: 440px;

h1 {
  margin: 0;
  font-weight: normal;

p {
  line-height: 1.25;

.row {
  margin: 0 10px 0 -10px;

.row::after {
  content: '';
  display: block;
  clear: both;

main .placeholder {
  float: left;
  width: 100px;
  height: 100px;
  margin: 10px;

aside {
  width: 140px;
  margin-left: 20px;

aside .placeholder {
  width: 140px;
  height: 320px;
  margin: 0 auto;

.warning {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  padding: 20px;
  border-top: 4px dashed #e8590c;
  background-color: #ffe8cc;
  color: #e8590c;
  text-align: center;

.no-support .warning {
  display: block;

.warning .fas {
  margin-bottom: 1rem;
  font-size: 1.5rem;
This CodePen's JS file has been "hijacked" to serve as the paint worklet file. The if check below ensures the code only runs when referenced as such. JavaScript for the page is at the top of the HTML. I'm only doing this to squeeze everything into one CodePen.

IMPORTANT: If you fork, update the CodePen JS file path in the HTML.

ALSO IMPORTANT: If you edit code here, disable cache and reload. Live preview won't pick up changes in the paint worklet.

if (typeof registerPaint !== 'undefined') {
  class PlaceholderBoxPainter {
    paint(ctx, size) {
      ctx.lineWidth = 2;
      ctx.strokeStyle = '#666';

      // draw line from top left to bottom right
      ctx.moveTo(0, 0);
      ctx.lineTo(size.width, size.height);

      // draw line from top right to bottom left
      ctx.moveTo(size.width, 0);
      ctx.lineTo(0, size.height);

  registerPaint('placeholder-box', PlaceholderBoxPainter);

External CSS

  1. https://fonts.googleapis.com/css?family=Mukta+Mahee:400,700
  2. https://use.fontawesome.com/releases/v5.0.6/css/all.css

External JavaScript

This Pen doesn't use any external JavaScript resources.