DEV Community

Discussion on: Never make your text container a flexbox container

Collapse
 
andreidascalu profile image
Andrei Dascalu

Just to nitpick.
You can't make your lowest level container a flexbox but your title is misleading to that. It's OK to make your text container a flexbox container as long as it's continuous text. A link it's not text (duh) so if you break your text with additional elements you get what you pay for.

Collapse
 
afif profile image
Temani Afif

It's OK to make your text container a flexbox container as long as it's continuous text. --> but there is a trap here. Consider the case where you don't know the exact content. You are pulling data from a database and in 90% of the cases it's plain text and one day you pull some text having a <strong> tag and boom, it's broken :)

Collapse
 
andreidascalu profile image
Andrei Dascalu

Well, yes, definitely. It's OK for text, which means that if you can't guarantee it is just that then you need to take measures depending on the end goal. One way could be like you said, to handle it for presentation only.

Although if you don't know what data you will receive I'd argue that you need to sanitize it to match your expectations and practices: eg if I don't expect html tags then I will sanitize the output (or better yet the input so that the dB content matches in the first place). If I do want to support tags then the presentation needs to be aware and be setup accordingly.

Thread Thread
 
afif profile image
Temani Afif

Even if you expect html and you want to have html the issue will still remain. How many developer are aware about how the output will be if the text will contain a link? how many beginners will even think that if I add a link to the above the result will look like I detailed? only few and this is what I am pointing here.

You may be aware about everything and you know perfectly your data but if you don't know flexbox very well you will get that surprise one day. I am trying to avoid you that surprice by explaining some quirks around flexbox that no one will explain to you until you face them ;)

Thread Thread
 
andreidascalu profile image
Andrei Dascalu

That is exactly what I'm saying. If you don't have guarantees it's just text then it's not just text and you don't treat it like just text (eg use a wrapper like you said or whatever fits the use case).
If you do expect just text then you implement the necessary safeguards and treat it like just text (case in which it's OK to just use the box setup).

Collapse
 
qm3ster profile image
Mihail Malo

It semantically doesn't make sense to make a container for some text / text document / html markup a flexbox. It doesn't matter whether you can or cannot get away with it in a given situation (no links, no idiomatic, no bring to attention, no headers, no lists, no code, no tables, no citations...)
Document-type html is expected to live in a "Normal Flow" container (not flexbox or grid)

Collapse
 
afif profile image
Temani Afif

This is the main point of this post because I see everyone using flexbox everywhere so I hightlighted one issue to convince them to stop doing this.

Some comments have been hidden by the post's author - find out more