<div class="not-supported"> Your browser doesn't support this demo. It is only supported in the latest version of Chrome Canary</div>

<div class="hello">Hello World. This text should increase its size when the screen gets bigger than 600px</div>
@function --suitable-font-size() {
  --size: 16px;
  @media (width > 600px) {
    --size: 40px;
  }
  result: var(--size);
}

/* Doesn't Work!*/
/* 
@function --suitable-font-size() {
  result: 16px;
  @media (width > 1000px) {
    result: 20px;
  }
} 
*/

.hello {
  font-size: --suitable-font-size();
}

/* Aesthetic Changes */

* {
  padding: 0px;
  margin: 0px;
}

body {
  display: grid;
  place-items: center;

  height: 100vh;
}

.hello{
  text-align: center;
  padding: 20px;
}

.not-supported {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 100vw;
  height: 40px;

  font-weight: 600;

  background-color: #ffbd59aa;
}

@supports (font-size: --suitable-font-size()) {
  .not-supported {
    display: none;
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.