0

Элемент * и body

* и body это одно и тоже, при указании в CSS ? К примеру, если я пропишу margin и padding в *, то мне нужно прописывать эти свойства в body ? А также, нужно прописывать свойство font-family в .CSS? Или лучше сразу прописывать font-family в HTML?

4th Aug 2018, 9:02 AM
Ibrahim
5 Réponses
0
* means all or everything This includes the html tag, which is the parent of the body tag, and all other tags. You may not have to specify the same thing in body, except if there is conflict in applying different styles. ( https://css-tricks.com/specifics-on-css-specificity/ ) I prefer to specify font-family in CSS because fonts are part of styling, so styles should go in the stylesheet.
4th Aug 2018, 9:13 AM
Janning⭐
Janning⭐ - avatar
0
That is, if, for example, I specify margin and padding inside *, then I do not need to specify the margin and padding properties in body? Generally, you do not need to specify the font-family in the HTML file? Or, it will not be a mistake?
4th Aug 2018, 9:24 AM
Ibrahim
0
I don't think the answer to your margin/padding question with the * selector versus the body selector is that simple. How important each browser thinks their user agent stylesheet is compared to your stylesheet differs. Some browsers are respectful of the developer's wishes and some are resistant, so you may have to explicitly declare padding/margin at the body level anyway. If you are asking if the * selector and the body selector do the same thing, the answer is no. If you apply padding/margin to the body selector, it will apply the padding/margin to the visible portion of the document once as a whole. If you apply margin/padding to the * selector, it will be replicated on every element (like putting two mirrors opposite each other). I keep all my font declarations in my stylesheet. It gets too messy to have styles in both the CSS file and the HTML file. The point of having external stylesheets is to be able to easily swap out stylesheets (themes) while leaving the content intact.
4th Aug 2018, 10:10 AM
Janning⭐
Janning⭐ - avatar
4th Aug 2018, 10:10 AM
Janning⭐
Janning⭐ - avatar
0
That is, I do not need to set margin / padding twice, just grab the margin and padding in *, and that's it?
4th Aug 2018, 10:19 AM
Ibrahim