T
T
Think With Your Head2015-10-03 17:13:21
css
Think With Your Head, 2015-10-03 17:13:21

Should I use inline styles or is it necessary to create a class/id?

Hello!
This problem often arises during layout: for example, the service has a bunch of forms, and there are textarea completely identical in style, only the height is different. So: is it really a good practice to produce entities in the form of separate (additional) classes / id for each of them, to write extra css lines when it is easier to set this height for them in inline styles in the html itself? Something like
<textarea style="height: 100px">
A also sometimes there are such nasty blocks that have a unique vertical padding in the layout, different from the vertical padding of the rest of the same blocks, and again there is a dilemma - is it really necessary to create a separate (additional) class / id for it, when it's easier to write margin-top inside the block
Or is there another way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Pavlenko, 2015-10-03
@Vyad

Yes, it's better to create a separate id or class.
Why?
Yes, because then there will be no questions: "how is this block positioned", and it's easier to trace in one file than to search later in dozens of others.
Even now I am refactoring the project, and I am faced with this problem - everything is done normally in the general file, and some properties are written using style. And this code is duplicated in different files, and changes a little, and it is not always easy to find in which file this property is generated (especially if it is a mixture of html, js, php)...

K
Ksenia Mikhailova, 2015-10-05
@arizona

If your form height depends on the height of the adjacent column, then it might be worth using a javascript to set the height.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question