2

Flex box "inlined" as html attributes: (sample taken from LumX website):

<div flex-container="row">
    <div flex-item>
        <lx-text-field label="Company" disabled="true">
            <input type="text" ng-model="textFields.disabled" ng-disabled="true">
        </lx-text-field>
    </div>
</div>

Or as CSS attributes:

  display: flex;
  flex-direction: row;

What is the recommended way to use flexbox? As css classes or as html attributes?

1 Answer 1

2

I think this is a somewhat subjective/relative question, as it might be a little a matter of preferences. That said, this is the first time I see inline Flexbox; all of the posts, tutorials, etc., I have seen on Flexbox have been made using CSS attributes.

It seems that the common practice is using CSS. Two reasons I come up with for doing so:

  • Separation of concerns: Inline CSS is usually discouraged because it messes content (HTML) with presentation (CSS). Separating them, makes it easier to maintain and modify the site.
  • Custom changes: You might need, for example, to use different layouts depending on the screen size (with media queries) or you might need to use vendor prefixes for browsers' support. In both cases, that would be better done with separate CSS code than with inline HTML.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.