<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/get-screen-size-in-pure-css-vsd3g1wbd" -->

---
title: Get Screen Size in Pure CSS | daily.dev
description: Learn how to use pure CSS to get screen size measurements, define custom properties, and perform mathematical operations on those properties. This method...
canonical: https://daily.dev/posts/get-screen-size-in-pure-css-vsd3g1wbd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Get Screen Size in Pure CSS | daily.dev
og:description: Learn how to use pure CSS to get screen size measurements, define custom properties, and perform mathematical operations on those properties. This method...
og:url: https://daily.dev/posts/get-screen-size-in-pure-css-vsd3g1wbd
og:image: https://api.daily.dev/og/posts/VSd3G1WbD.png
og:image:alt: Get Screen Size in Pure CSS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Screen Size in Pure CSS

**[DEV](https://daily.dev/sources/devto)** · 3 min read · 809 upvotes · 29 comments

## Summary

Learn how to use pure CSS to get screen size measurements, define custom properties, and perform mathematical operations on those properties. This method updates in real-time without JavaScript, utilizing new CSS features like @property, atan2, and tan functions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dev.to/leapcell/get-screen-size-in-pure-css-3kna>

## Community discussion

Top comments from developers on daily.dev.

**@ronaldtveen** · 7 upvotes

> I like it, quite simple without having to jump over to JS to set properties as inline styles and keeping them in sync.
>
> Question is though, how is the performance?

**@vaxul** · 5 upvotes

> Wild, that something like this is possible in CSS. :D

**@thr4sher** · 3 upvotes

> thanks for sharing!

**@giorgsiap** · 2 upvotes

> Very cool stuff!! Nice...

**@alexander093** · 2 upvotes

> I'm a newbie at this.
>
> Could someone tell me the useful practices of this?

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript), [#css](https://daily.dev/tags/css), [#html](https://daily.dev/tags/html), [#frontend](https://daily.dev/tags/frontend), [#ui-design](https://daily.dev/tags/ui-design)

[View this post on daily.dev](https://daily.dev/posts/get-screen-size-in-pure-css-vsd3g1wbd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Get Screen Size in Pure CSS","url":"https://daily.dev/posts/get-screen-size-in-pure-css-vsd3g1wbd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/get-screen-size-in-pure-css-vsd3g1wbd"},"datePublished":"2024-09-03T15:05:48.411Z","dateModified":"2024-11-08T07:53:01.457Z","description":"Learn how to use pure CSS to get screen size measurements, define custom properties, and perform mathematical operations on those properties. This method...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4902ad0c9afb946f8fb5c5b52d4e8593?_a=AQAEuiZ","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4902ad0c9afb946f8fb5c5b52d4e8593?_a=AQAEuiZ","isAccessibleForFree":true,"articleSection":"DEV","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DEV","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/devto","url":"https://daily.dev/sources/devto"},"commentCount":29,"discussionUrl":"https://daily.dev/posts/get-screen-size-in-pure-css-vsd3g1wbd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":809},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":29}],"keywords":"webdev,javascript,css,html,frontend,ui-design","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DEV","item":"https://daily.dev/sources/devto"},{"@type":"ListItem","position":3,"name":"Get Screen Size in Pure CSS"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/get-screen-size-in-pure-css-vsd3g1wbd","comment":[{"@type":"Comment","text":"I like it, quite simple without having to jump over to JS to set properties as inline styles and keeping them in sync.\nQuestion is though, how is the performance?","datePublished":"2024-09-04T07:51:08.815Z","url":"https://daily.dev/posts/VSd3G1WbD#c-dcUfndFdU","author":{"@type":"Person","name":"Ronald","url":"https://daily.dev/ronaldtveen","image":"https://media.daily.dev/image/upload/s--9OwvzKjX--/f_auto/v1722926993/avatars/avatar_0A9MVFYSIzGn5rY4WrvpB"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":7}},{"@type":"Comment","text":"Wild, that something like this is possible in CSS. :D","datePublished":"2024-09-04T05:56:16.566Z","url":"https://daily.dev/posts/VSd3G1WbD#c-jwKsPnZZg","author":{"@type":"Person","name":"David","url":"https://daily.dev/vaxul","image":"https://media.daily.dev/image/upload/s--uGg1p2G2--/f_auto/v1723011421/avatars/avatar_c4XEAXU1WcB64CxDpZv1o"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5}},{"@type":"Comment","text":"thanks for sharing!","datePublished":"2024-09-04T07:13:52.432Z","url":"https://daily.dev/posts/VSd3G1WbD#c-7xvVXVqnv","author":{"@type":"Person","name":"Enrico Monzeglio","url":"https://daily.dev/thr4sher","image":"https://lh3.googleusercontent.com/a/ACg8ocKbIkCMxXbTQmI2l-YIyQgSBHxVYaPcavVG8__58QST-_Q=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"Very cool stuff!! Nice…","datePublished":"2024-09-04T07:31:25.874Z","url":"https://daily.dev/posts/VSd3G1WbD#c-8sWhhsyl3","author":{"@type":"Person","name":"George Siaperas","url":"https://daily.dev/giorgsiap","image":"https://media.daily.dev/image/upload/s--lJ2phuXK--/f_auto/v1725268780/avatars/avatar_PZbDdUgdEp9OoI67ZOLUW"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"I’m a newbie at this.\nCould someone tell me the useful practices of this?","datePublished":"2024-09-09T06:52:17.144Z","url":"https://daily.dev/posts/VSd3G1WbD#c-vdEDg5fwT","author":{"@type":"Person","name":"Alexander","url":"https://daily.dev/alexander093","image":"https://avatars.githubusercontent.com/u/134494622?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}}]}
```

