<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-css-sign-function-rt3gimoma" -->

---
title: The CSS sign() Function | daily.dev
description: The CSS `sign()` function returns `1`, `-1`, or `0` based on whether a math expression is positive, negative, or zero. It enables conditional styling logic in...
canonical: https://daily.dev/posts/the-css-sign-function-rt3gimoma
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The CSS sign() Function | daily.dev
og:description: The CSS `sign()` function returns `1`, `-1`, or `0` based on whether a math expression is positive, negative, or zero. It enables conditional styling logic in...
og:url: https://daily.dev/posts/the-css-sign-function-rt3gimoma
og:image: https://api.daily.dev/og/posts/RT3GimOMa.png
og:image:alt: The CSS sign() Function
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.

# The CSS sign() Function

**[CSS](https://daily.dev/sources/iheartcss)** · [@geoffgraham](https://daily.dev/geoffgraham) · 2 upvotes · 0 comments

## Summary

The CSS `sign()` function returns `1`, `-1`, or `0` based on whether a math expression is positive, negative, or zero. It enables conditional styling logic in pure CSS without JavaScript — for example, toggling tooltip direction, switching colors, or rotating elements based on a variable's sign. Combined with `clamp()`, it can act as a binary switch to apply different styles for positive vs. negative values. Key caveats: it always returns a unitless number (must be multiplied by a unit before use), it operates on resolved values rather than raw values (which can surprise with percentages), and it returns `NaN` for invalid calculations like division by zero.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://css-tricks.com/almanac/functions/s/sign/>

## Similar posts on daily.dev

- [CSS-Tricks](https://daily.dev/posts/css-tricks-gktqweqqg) · CSS-Tricks · 10 upvotes · 1 comments
- [CSS Infinity Use Cases · July 25, 2026](https://daily.dev/posts/css-infinity-use-cases-july-25-2026-wwuly17lm) · Adam Argyle · 10 upvotes · 2 comments
- [The “Most Hated” CSS Feature: asin\(\), acos\(\), atan\(\) and atan2\(\)](https://daily.dev/posts/the-most-hated-css-feature-asin-acos-atan-and-atan2--zbn43uros) · CSS-Tricks · 4 upvotes · 0 comments
- [Fallbacks for CSS \`progress\(\)\` – Master.dev Blog](https://daily.dev/posts/fallbacks-for-css-progress-master-dev-blog-uogyas7vh) · Frontend Masters · 4 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/the-css-sign-function-rt3gimoma)

```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":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/the-css-sign-function-rt3gimoma","headline":"The CSS sign() Function","text":"Shared: CSS-Tricks","url":"https://daily.dev/posts/the-css-sign-function-rt3gimoma","datePublished":"2026-02-19T15:38:46.082Z","dateModified":"2026-02-19T15:39:50.114Z","author":{"@type":"Person","name":"Geoff","url":"https://daily.dev/geoffgraham","image":"https://media.daily.dev/image/upload/s--mXp5yqc7--/f_auto/v1746709785/avatars/avatar_JAehePvXH6nu6u9F4E9YV?_a=BAMClqUq0","description":"Certified Neat Freak","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":940}},"image":"https://media.daily.dev/image/upload/s--2-1xRawN--/f_auto/v1722860399/public/Placeholder%2011","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/CSHJjFiMF"},"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/iheartcss","name":"CSS"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"CSS","item":"https://daily.dev/squads/iheartcss"},{"@type":"ListItem","position":3,"name":"The CSS sign() Function"}]}
```

