CSS Text Box Trim
github.com
github.com
The two most needed CSS properties for better web typography are Text-Box-Trim, as well as Margin-Trim
Please browser dev’s, implement both of these.
https://developer.mozilla.org/en-US/docs/Web/CSS/margin-trim
—-
Here’s a JS hack in the mean-time:
Is it designed to do more than just that, or is it just about avoiding gaps at the start and end of lines of elements?
Flex with gap is also an alternative to that, and in my view should be the default thing you reach for. But there are some cases where the child margin approach has benefits, particularly if you're doing certain animations/transitions or if you want each child to essentially override its top or bottom gap.
Like, I understand the situation, I've been in that place plenty of times. But I've never felt in want of a solution there.
* {
margin: 0;
padding: 0;
}
* + * {
margin-top: 1em;
}This feature would fix alot of the problems with centering fonts (icon and text) vertically, which is currently not really possible, at least not easily.
Looks like Safari beta is the only current option.
It's always funny how Safari gets so much heat on HN for being "behind" on things, when it's so often ahead on features.
For example, it's the only browser that supports hanging-punctuation, and supported JPEG2000 since 2011.
Their TP finally implements it, but years late.
Safari is the only thing stopping Google from running rampant with implementing new "web standards" because all browsers on the iPhone are Safari, so everyone needs to make sure their site works in a browser other than Chrome.
This is looking to be on borrowed time unfortunately because regulators are looking to force Apple to allow other browser engines. So look forward to Google's stranglehold on the internet being further cemented.
So when it comes to presentation (how text is presented, typography, color spaces, HiDPI, etc, all things that benefit an overall design, user experience) Safari always seems to be way ahead of the rest.
But when it comes to stuff that developers want (stuff that mostly makes devs more happy), it may tend to lag more behind.
That mirrors Apple's general priorities of often prioritizing user experience over dev experience.
And even though I'm a developer, I happen to kind of agree with that prioritization..... on most days :-)
They never stray from that.
To be fair to HN this has been a relatively recent change. Jen Simmons and Webkit/Safari teams have really stepped up their game.
It's very easy to dismiss any web improvement as being something Google is shoving down everyone's throat but it's not true, a lot of them are things developers are crying out for.
They’ve recently started investing more in the browser, but haven’t moved on degrading battery life. I wonder why they’re suddenly investing (cough cough DMA)
or what developers like myself want. There was absolutely a significant period of time where it felt like I was dealing with the new IE in the age of evergreen browsers.
That's a pretty big thing. I did not know.
I have custom elements on this web page, but I haven't had anyone complain that the image doesn't show (or shows up twice) under iOS: https://www.lelanthran.com/chap10/content.html
E.g. they were also first to support the `:has()` selector/pseudo-class, which I think can be useful for avoiding JS in some cases.
That's not what it is. It's a typographic control that wasn't available in browsers before. It's got nothing to do with fonts being badly made. All textboxes (no matter which font) can be measured from many different places, and this lets you specify (via text-box-edge) which of those many different places you want to consider as the bounds of a specific textbox.
Not to mention Webms, PWAs, pointer support, etc...
For 12 years visually vertically centreing text has required adding a padding or margin of a few pixels to the bottom or top, now (when adopted) it can be done properly.
https://css-tricks.com/leading-trim-the-future-of-digital-ty...
Note: this use to be called “leading-trim”
Yes, you can sometimes add a little space around the text, but this is a proper solution.
Bookmarked, will get back to it in 10 years.