Strawberry,

cool flex bro

Blackmist,

Centering things on a web page is so easy.

I also have to look it up every single time.

redcalcium,

Back in the day we didn’t have flex and had to use dark arts to center divs. Young frontend devs these days have it easy. Heck, back in the day there is no frontend devs, just cgi-bin programmers. Get off my lawn!

Bye,

I don’t do web dev, I write math software that makes very rich people richer. But I often hear of this centering and layout crap

Why doesn’t html just have hcenter and vcenter tags or something? Why is centering so hard?

lorty,
@lorty@lemmygrad.ml avatar

As a frontend dev: who knows?

xigoi,
@xigoi@lemmy.sdf.org avatar

HTML has moved on from non-semantic tags a long time ago, and centering is easy with modern CSS.

Kolanaki,
@Kolanaki@yiffit.net avatar

Since when does HTML not have a simple centering tag?

Edit: Since HTML5 apparently. Wow wtf?! I haven’t actually used HTML since I was in high school. That’s wild.

Bye,

deleted_by_author

  • Loading...
  • kameecoding,

    well with the css grid and flexbox it’s no longer a problem.

    BlackEco,
    @BlackEco@lemmy.blackeco.com avatar

    Why doesn’t html just have hcenter and vcenter tags or something?

    HTML is a markup language, its purpose is to structure documents, while CSS can be seen as an additional layer that allows you to style and alter the layout of HTML documents. Because of this philosophy, it wouldn’t make any sense to have such tags.

    ICastFist,
    @ICastFist@programming.dev avatar

    It actually has <center> for centering things horizontally. Yes, it’s literally <center> content </center>. It’s been around since the early 90s, too. Dunno about a vertical center</center>

    Thorned_Rose,
    Thorned_Rose avatar

    Center tag is deprecated in HTML5

    BlackEco,
    @BlackEco@lemmy.blackeco.com avatar

    center is mostly for centering text and is being deprecated in favor of text-align and margin-*: auto developer.mozilla.org/en-US/docs/Web/…/center

    sunbytes,

    “We have justify-content and align-items at home”

    30isthenew29,

    Flex.

    BlackEco,
    @BlackEco@lemmy.blackeco.com avatar

    I wasn’t expecting this to work, and yet it does: css-tricks.com/the-peculiar-magic-of-flexbox-and-…

    When Sam says, “that item will automatically extend its specified margin to occupy the extra space in the flex container,” the way my empty filing cabinet brain interprets that is like so:

    Setting the margin property on a flex child will push the child away from that direction. Set margin-left to auto, the child will push right. Set margin-top to auto and the child will push to the bottom.

    […]

    Why is this useful to know? Well, I think there are a few moments where justify-self or align-self might not get you exactly what you want in a layout where using auto margins gives you that extra flexibility to fine-tune things.

    SaintWacko,

    Hell, I’m a web dev and I’d pay someone to center things for me

    BusterStatus,

    For real. When I have a front-end story to do, I basically just slam on the keyboard until it looks close to how UX wants it.

    FredericChopin_,

    I usually just try justify-content, justify-items, align-content, and align-items. Then when it gets centered I remove the rest.

    I’m not paid to remember, I’m paid to know it’s possible.

    SaintWacko,

    Same! I usually open the dev console and just flip through all the options until I find the one that does it

    ICastFist,
    @ICastFist@programming.dev avatar

    <center></center>

    That’ll be 200 dollars

    Rolando,

    Great, now make it blink.

    Agentseed,

    I still use <center> tags on some things, it's quick and I'll fix it when it eventually breaks

    gornius,

    Co-pilot?

    magic_lobster_party,

    Weird flex, but ok

    Zucca,

    Hehe.

    I see what you did there.

    Andrew15_5,
    @Andrew15_5@mander.xyz avatar

    It’s not weird, it’s powerful!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programmerhumor@lemmy.ml
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • GTA5RPClips
  • rosin
  • thenastyranch
  • Youngstown
  • InstantRegret
  • slotface
  • osvaldo12
  • kavyap
  • khanakhh
  • Durango
  • megavids
  • everett
  • cisconetworking
  • normalnudes
  • tester
  • ngwrru68w68
  • cubers
  • modclub
  • tacticalgear
  • provamag3
  • Leos
  • anitta
  • JUstTest
  • lostlight
  • All magazines