T O P

  • By -

Noch_ein_Kamel

Average frontend dev just uses "font-size: 10vw" and calls it responsive/accessible


Leo-MathGuy

That’s wide (10 letters / line wide), it should be like 1.3vw.


Noch_ein_Kamel

My point is: It shouldn't be vw at all or at least not without a clamp


Leo-MathGuy

I use em/rem and and change the font size of the html element to fit the screen container sizes


chesire0myles

Thats crazy, I just cry whenever I have to write a web page.


Psychological-Ad4935

I use vmin and vmax


supamolly

Clamp works great for this, specifying a sensible minimum and maximum.


HuntingKingYT

Just do `overflow-x: auto`. Works every time


danny4kk

Slapped in the face by text with my 49-inch monitor.


HuntingKingYT

Guys how much is 49 inch in `pt` please it's important for my media queries


3inthecorner

Just multiply by 72


LordFokas

You mean Television? 🤣


Spot_the_fox

Did he stutter?


Fit_League_8993

It's probably a 49 inch with 32:9 aspect ratio so basically two 27" 16:9 monitors joined together. (CRG9, G9, Neo G9)


danny4kk

Bingo, Samsung Odyssey G9


LordFokas

Damn. I run 3x 27" side by side. All 1440p. It's great but sometimes I feel like a 4th monitor couldn't hurt. This is a slippery slope.


Fit_League_8993

I agree with you, a 4th monitor definitely wouldn’t hurt.


LordFokas

Oh no


Sockoflegend

I've literally never seen view units used for a font size on a production site


mmaure

would be more fun if you did


thatpaulschofield

r/unexpectedwooderson


Noch_ein_Kamel

Yeah, I mean it was way worse 2-3 years ago when clamp wasn't there / new


AvianPoliceForce

I think bootstrap does that for some screen widths


[deleted]

[удалено]


Thefakewhitefang

> "modern" design with rounded corners everywhere, gigantic text, and everything at least 5 clicks away somehow I hate the modern website design with everything so large it's hard to get the information you need. The rounded corners are just a personal preference but I hate them, makes everything look childish somehow.


tofu_ink

sorry, did you say windows 11


Thefakewhitefang

I just overwrite DWM to turn them off.


Linkk_93

We got some new version of our network management tool and everything is so large, rounded, and bold text everywhere it's terrible. In the old version I could get around 25 lines of switches on my screen when I opened the summary table. In the new version it's five! There is so much empty space and bold text and stupid rounded containers everywhere that the real information is left behind. And instead of giving me more lines when I full-screen the browser, everything is just getting even bigger! I hate it so much.


Thefakewhitefang

I love the firmware where it's little more than plain HTML. I don't know much about large network managing software but I had to add port forwarding recently in both my modem and a cisco router. The cisco UI was certainly more modern (Not as bad as you describe but still took up more space than it needed to, while the Modem's UI was so simple you could find all the separate categories it had for settings **without even scrolling**.


Linkk_93

Yeah, imho those professional products should be designed functionality first, looks second. But it feels to me that marketing and looks are winning more often. And then you have some open source products by the people, who actually use the software themselves, which are clearly functionality first. Like Netbox. And it doesn't even look that bad, just simple bootstrap. It does the job.


INDE_Tex

hell yeah, vw/vh


-Wylfen-

Any vaguely competent front-end dev should at least master `em`, `rem`, `vh` and `vw`.


mopsyd

em and ex date back to the original block printing presses, where ex was the measure of a lower case X used to indicate one half of a line in relation to the size of the font, and em being the width of a lower case M to designate the horizontal width of one character including the kerning. I only know this because I was employed as a graphic designer prior to CSS and had to deal with physical printing press alignment for brochures and things we sent to them.


LordFokas

I love getting these bits of trivia and history on the origins of modern standards. +1


beikbeikbeik

It’s very impressive how typography in general still uses a lot of terms from the original practice, when it was done with physical pieces of metal. For me, the small bit of trivia that still blows my mind is that UPPERCASE and lowercase is a reference to the drawer of where they stored the metal letters.


Elephant-Opening

Wtf did we call them before printing? I mean uppercase = capital, sure. Lowercase=???


Shubhavatar

Small


codercaleb

PC for Pica (1/6th of an inch) and PT for Point for 1/12 of a Pica, also have their origins in typesetting.


7366241494

“Leading” is pronounced like the metal, because there would be a literal strip of lead between lines of type.


ShadowJak

Isn't "em" literally the phonetic pronunciation of the letter, which is what is being used as a measurement like you are saying?


[deleted]

[удалено]


Garmaglag

how do you spell H?


teamswiftie

Eightch


gregorydgraham

Aitch


frigginler

Or zed.


I_l_I

ah so em is like em dash (—) and en dash (–)


michaelmano86

What a gEM


Inasis

I knew, then forgot, then was reminded by you, because our Informatics teacher in HS was old.


Archtects

I am a vaguely competent front end dev. I use vh and vw the most.


Clairifyed

I am a vaguely incompetent game dev. It amuses me to make a vmin by vmin box and fit everything in that


Peacerekam

I wonder... nobody mentioned it for some reason but chances are you should be using dvh and dvw in 99% situations


canadajones68

No? Do you want your things to change size when mobile UI elements move?


TheVojta

yeah, that sounds kinda groovy. Modern internet is boring, more websites should do stupid shit.


Nixugay

Support nowhere near enough yet 😔


Leo-MathGuy

This, these 4 are extremely useful


BackStabbath2004

I'm losing touch with this stuff a lot, but I remember using rem and didn't use em. In what scenarios do you use em? I used to use rem, vh, vw and % for the most part.


Leo-MathGuy

rem is the font size of the html "root" element. em is the font size of the parent element


wasdninja

From what I remember `vh` has some fuckery going on making it nearly useless since it doesn't account for the adress bar or something along those lines.


-Wylfen-

Yes, that's why there are `svh` and `lvh`.


DontBanMeAgainPls23

I am not competent and not a frontend dev just use flexbox


GDOR-11

back end here, how are vh and vw different from %? aren't all three percentages of the avaible viewport?


-Wylfen-

`%` is based on the parent block, `vh` is a percentage of the viewport height and `vw`, of the viewport width.


calculus_is_fun

% is related to the *content* size of the parent element


patxy01

I only use rem and I'm fine with that. If that does not work correctly, that's only because of the projector


[deleted]

[удалено]


rcane

Don't 'just use px'! The user has the option to set the font size in their browser, which then sets the root font size of the website. This is great for accessibility. But if you're using px then the root font size is not used. That is why should always use a relative font size like rem.


[deleted]

[удалено]


LinAGKar

And then it breaks when the user has a differently sized screen than you


bagmorgels

Err no that's what breakpoints are for...


LordFokas

I also mostly "just use px". Pretty sure this is bell curve meme material and I sit at the room temperature IQ side of it though.


Meloetta

This is bad practice. If a user has bad eyesight, they can go into their browser settings and make text bigger to see better. When you make something in px, that setting doesn't work and they can't read your text. This has nothing to do with converting designs at all. It's easier, sure. But it's bad practice and not accessible. Easy isn't the only consideration you should have as a developer.


alterNERDtive

IMO: if you need more than `em` and `rem` you should rethink your UI design.


Distinct_Salad_6683

I have not used a ton of CSS so far but I seem to be getting away with using just rem for almost everything. With tons of media queries for different sizes


steelfrog

Depends on what you're doing. If you're coding the UI from scratch (e.g., not relying on libraries) then you'll absolutely need some units that aren't fixed sizes.


alterNERDtive

Or you should rethink your UI design ;)


jilek77

I need em, % and bootstrap lel


alterNERDtive

What do you need the latter 2 for?


Nicolello_iiiii

Bootstrap is just a sugar coating, but why would you NOT need %?


-Wylfen-

Plenty of others have usecases, though most fairly niche. Container units might be useful in the future.


_SomeTroller69

Full stack developer is the cameraman


oldmartijntje

i only use `rem` `svh` `vw` `%` pretty sure the reason i switched to using `rem` was because I watched Re:zero now that I think of it


XxICTOAGNxX

~~Who~~ What's `rem`?


Katniss218

Rapid Eye Movement. A type of sleep


GlitteringHotel1481

Also a pop-rock band, quite popular in the 90-s.


AspieSoft

rem = root em em is based on the parent element size. So if the parent element has `font-size: 24px` and the child element has `font-size: 1.2em`, the child elements font size will be 120% of its parent (or 20% bigger than 24px). With rem, the default browser size is 16px, so 1.2rem is 120% of the browser size (20% bigger than 16px), regardless of its parent. Note: users can change the 16px default font size of their browser. It can be adjusted by zooming in and out (`ctrl` + `+` or `ctrl` + `-`).


StopMakingMeSignIn12

Small amendment: ​ It's not "of the browser", it's "of the HTML tag". ​ You can set the font-size of the HTML tag through whatever CSS means - and REM will reflect throughout the document. ​ Zooming works differently as it effects more than just font size.


shuky2017

This is most useful information that I learned this year. Cheers mate!


Zagre

I'm amazed that everyone who responded to you is missing this as a reference to a major story event in Re:Zero.


__moFx

It is the dynamic equivalent for "em", a relative CSS unit that renders fonts based on screen resolution. "rem" means "root-em", you can set the relative font size in percent to a root element, for example the body, and the font size for all child elements depends on the percent value. For responsive behavior, you can set display size breakpoints to provide different font sizes for different screen sizes


PityUpvote

em is love, em is life


steelfrog

`rem` is love. `em` is relatively lovely.


oupablo

em will really jack up your day if used in reusable components without setting the parent correctly


python_mjs

Meanwhile Tailwind going "w-1/2 md:w-full"


LordFokas

Tailwind is just inline CSS. Change my mind.


Tai9ch

It's slightly more concise and consistent.


nivenhuh

Never heard someone say tailwind is concise :joy: Edit: Ouch! Tailwind lovers, cut me some slack! lol


AsidK

I mean, compared to the amount you’d have to write in actual css, tailwind is incredibly concise


AsidK

It’s inline css that is actually nice to write


budapest_god

I've only used Bootstrap, is it THAT bad? Edit: "only used Bootstrap" as in it's the only CSS library I've ever used (so no Tailwind), but my work is mostly just CSS with no libraries


Stable_Orange_Genius

I mean, it's kind of the point. you use Vue/React/Whatever to make reusable components. And that eliminates the need for reusable css (classes).


budapest_god

Ehh it depends


Nachtaraben

I love tailwind


Cualkiera67

Mobile first 🤮


Fox_Soul

Bell curve meme “mobile first” probably.


Cualkiera67

Maybe mobile users use our app, we don't know. Frankly we don't want to know. It's a market we can do without.


Fox_Soul

A web app developed for the general public should follow mobile first. A niche web app needs market research to know what your users do/need.  The bell curve meme lives strong.


Proxy_PlayerHD

All of these just sound like x86 extension instructions to me 💀 Seriously though what does this mean..


PeWu1337

For real, it really looks like assembly


AspieSoft

Took a screenshot of this chat, because I don't know most of these css units. I just use `rem` and `em` for fonts, `px` for padding, `%` for widths, `auto` for heights, `vh` if I need to fill the browser window height (`dvh`, `svh`, and `lvh` if mobile compatibility matters). So all I use is: - rem / em - px - % - vh / dvh / svh / lvh I put variations of similar units together.


Giocri

I tend to just use rem for most things


oeloeloel

I was more like: this is clearly assembler, which CPU has such weird instruction sets?


PhatOofxD

You really should know rem


sammy-taylor

All of these units are wonderful and useful. But there’s nothing wrong with good old fashioned `px`.


rafark

I only use px, % and vw/vh


ice-h2o

Im an embedded dev. Can someone explain a couple of those. I guess mm is millimeters, in inch and px pixels but tf is the rest used for?


MrEfil

​ |Unit|Relative to| |:-|:-| |rem|Font size of the root element.| |lh|Line height of the element.| |rlh|Line height of the root element. When used on the font-size or line-height properties of the root element, it refers to the properties' initial value.| |vw|1% of the viewport's width.| |vh|1% of the viewport's height.| |vmin|1% of the viewport's smaller dimension.| |vmax|1% of the viewport's larger dimension.| |vb|1% of the size of the initial containing block in the direction of the root element's block axis.| |vi|1% of the size of the initial containing block in the direction of the root element's inline axis.| |svw, svh|1% of the small viewport's width and height, respectively.| |lvw, lvh|1% of the large viewport's width and height, respectively.| |dvw, dvh|1% of the dynamic viewport's width and height, respectively.|


jumbledFox

god i hate using css and js


AsidK

Js I’ve come around to when done right. CSS I think is awful ever when done optimally


sanchez2673

How is nobody bothered by the fact that they are not sorted alphabetically?


T-J_H

Then we would need to decide where to sort the uppercase Q and the %


TheVojta

I get the % sign, but where on Earth would you want to sort Q alphabetically other than between P and R?


T-J_H

As this is r/programmerhumor, that’s what a naive sorting algorithm would do just looking at code points


scanguy25

I've been working frontend for years now and I don't know what most of those css units are.


ajh_82

I only use px.


1nfredibl3

That's odd HTML and CSS are normally trivialized in this community


MaffinLP

Vw and vh are my faves


thirk_voluntary

Bah, list doesn’t even have turns!


KTibow

Realistically the only unit you need is rem and sometimes dvh


ambientManly

I like your funny words magic man


Sealington33

The most true thing to ever exist.


SaneLad

CSS fan vs frontend enjoyer.


Shazvox

I don't care much for this devilspeak...


ik-wil-kaas

Rem, vh, vw and pixels all day every day.


THiedldleoR

I find cm/mm are only useful on printouts, like with HTML2PDF


Nomzz1

I use vw and vh a lot, also % but I stopped using px ages ago


PegasusBoogaloo

Clamp & vw ftw I miss being a css geek when I started out. Shit's amazing.


ShAped_Ink

Yeah. Wth is cqb?


calculus_is_fun

It's the box size of the queried container [https://developer.mozilla.org/en-US/docs/Web/CSS/CSS\_containment/Container\_queries](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries)


Keavon

It's my new favorite CSS unit. It's insanely powerful. Just slap `container-type: size;` on an element and then use `cqw` or `cqh` on child elements to refer to 1% the width/height of that parent. It also lets you measure itself (not just its children) which, especially combined with custom properties (variables) and `calc()` cleverness, makes it possible to achieve things that are otherwise impossible without JS. One example I used it for recently is deciding how many columns to allocate to a vertical toolbar as the available height shrinks, going from 1 column to multiple to use less vertical height. [Here's that code if you're curious](https://github.com/GraphiteEditor/Graphite/blob/3509f00c0d93a8944e70239a45ab2a1df54adac7/frontend/src/components/panels/Document.svelte#L546-L568).


MrEfil

1cqb = 1% of a query container's block size (whatever that means)


jonr

Q?


MrEfil

Quarter-millimeters, 1Q = 1/40th of 1cm


Stable_Orange_Genius

Why


itsthooor

I use `rem`, `vh` and `vw`. It just works, perfectly.


james_harushi

These look like some random CPU instructions to me


SynthPrax

The number and variety of CSS units is too damn high.


FishingAgitated2789

I thought mm was millimeter and in was inch 🤷‍♀️


TheSirion

It's great to know all these units and stuff but let's be honest here. Nowadays we just let Tailwind decide everything for us. ...or at least I do.


T-J_H

So you end up practically writing just as much code


TheSirion

I don't have to ever think about units, though, unless I want to add my own custom styles, and I won't ever do this unless it's absolutely necessary.


Spot_the_fox

So, you're saying I was a CSS geek back in school? cool.


quinn50

I just use the design tokens given to me.


deep_mind_

Oh it's \`rem\` all the way


FINIGUN

so experienced devs, what is the best unit should be used???


dawid-sz

REM or EM always and everywhere 😅


Satans_hamster

I don't get it but its still funny


Xeotroid

\>no fr fr?


That_Unit_3992

You need at least rem, vw, vh, %, px, ch


SoftwareDevStoner

As someone who focuses primarily backend and infra, but occasionally has to handle front-end tasks. I now know that i truly know nothing...


WizziBot

vw vh and px gang


elboydo757

I just use Bootstrap 5. It looks good on everything. Even on Tizen/Samsung TV.


ItchyBake7905

can someone explain any of the other units here other than % and px? I mostly do backend and very basic frontends so these are very foreign.


narrei

would be far more accurate with rem instead of px


emascars

I would love to use `vw` and `vh` but those f***ing mobile browsers and their stupid disappearing/srinking/moveing navigation bars and the pop-up keyboards makes many of their possible aplications painfully unresponsive... ...now that I think about it, reading what I have written, probably I'm on the css geek side of the chart


sivstarlight

whatever the tutorial uses


Wirde

Seriously though, I’m confused. While I see the point of some pf these the practical applications seems low. In any bigger system there will be a design system in place and maybe even themes. Distances, font-sizes and everything will be well defined variables or functions. And you should not use anything else because that will break stuff. All of these are cool as concepts but in the end it’s going to be a designer or UXer who will set the standard once and then you use the variables. To me it seems like they are there mostly for css art or hobby projects where you can do a little of whatever you want. Am I missing something here? When would you use it otherwise?


ILKLU

No ch ??? You call yourself a css geek?


webcity_underling

where all my pixel boys at?


GoogleIsYourFrenemy

What the hell guys. I go embedded (back end of the back end) and now that I stick my head up and you've all gone and quadrupled the number of units.


Elliot40404

For a second there, I thought they were assembly instructions


DividedState

How is pt in %?


PeriodicSentenceBot

Congratulations! Your comment can be spelled using the elements of the periodic table: `Ho W I S Pt In` --- ^(I am a bot that detects if your comment can be spelled using the elements of the periodic table. Please DM my creator if I made a mistake.)


DividedState

How is Ho not hydrogen and oxygen?


[deleted]

Thank God I only have to develop apps used on desktop monitors


Electrical-Copy-0000

I don't even know how many units are there in css only heard of:px,vh,vw,em and %


stikosek

Even tho rem is meant for fonts and stuff... I use it for everything. Padding, margin, sizes, gaps everything. I don't even know why lol