As far as I know, the none keyword is not a value of the margin CSS property. The value of the margin CSS property can either be auto keyword, length or percentage value, or one of the global values (inherit, initial, revert, e.t.c.). Something like:
margin: auto;
margin: 0; /* No need for unit if the value is 0 */
margin: 2px;
margin: -2px;
margin: 2%;
Thank you for your explanation. However, I have coded in CSS before and required to give “value” to properties that were “none”. So are you telling me that each property in CSS (whatever/whichever it may be) already has a pre-determined “value” that it will accept or work with? If that’s the case, it will make total sense that the putting “none” as a value for “margin” will not work. Am I correct in my reasoning here?
Yes. Your reasoning is correct. Each CSS property has values it accepts. Like I mentioned above, none is not a value of the margin property. You can always look up all the values accepted by a CSS property in the documentation.
If it helps from a logical standpoint, margin is a size, just like padding, width, height, etc… so you need to specify a number, or specify a sizing instruction (like auto). You can’t have a margin that is ‘none’ wide.
‘none’ works in settings where you aren’t specifying a size, but rather specifying a feature, like background color. You might argue that you can specify ‘none’ for border instead of say ‘2px’, but border is not a size value, but rather object, as you can use ‘border:’ to specify type, color, etc. You can’t put ‘none’ in ‘border-width’… although that one does have an option to specify ‘unset’.
As nibble said, if unsure, reference the documents, it will tell you all the settings that work for a particular property, just thought I’d throw in the logic as I understand it.