Hege Rokenes
Hege Rokenes

Reputation: 85

Are there reasons to not mix units in CSS?

When doing responsive designs I often need to have a percentage margin horizontally, but vertically I usually don't want to have percentage, but rather fixed pixels.

Are there any reasons why I shouldn't be mixing units in my margins and paddings like this:

margin: 10px 10%;

Browser performance? Cross browser rendering issues?

Upvotes: 4

Views: 1737

Answers (1)

Kory Sharp
Kory Sharp

Reputation: 490

As long as you're maintaining that vertical is pixel based and horizontal is percentage based, you should be fine. Just don't mix the two (at least not within a single element), or you'll get undesired effects across the board.

Upvotes: 4

Related Questions