Š­Š»ŠµŠ¼ŠµŠ½Ń‚ * Šø body | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Š­Š»ŠµŠ¼ŠµŠ½Ń‚ * Šø body

* Šø body этŠ¾ Š¾Š“Š½Š¾ Šø тŠ¾Š¶Šµ, ŠæрŠø уŠŗŠ°Š·Š°Š½ŠøŠø Š² CSS ? Šš ŠæрŠøŠ¼ŠµŃ€Ńƒ, ŠµŃŠ»Šø я ŠæрŠ¾ŠæŠøшу margin Šø padding Š² *, тŠ¾ Š¼Š½Šµ Š½ŃƒŠ¶Š½Š¾ ŠæрŠ¾ŠæŠøсыŠ²Š°Ń‚ŃŒ этŠø сŠ²Š¾Š¹ŃŃ‚Š²Š° Š² body ? Š тŠ°ŠŗŠ¶Šµ, Š½ŃƒŠ¶Š½Š¾ ŠæрŠ¾ŠæŠøсыŠ²Š°Ń‚ŃŒ сŠ²Š¾Š¹ŃŃ‚Š²Š¾ font-family Š² .CSS? Š˜Š»Šø Š»ŃƒŃ‡ŃˆŠµ срŠ°Š·Ńƒ ŠæрŠ¾ŠæŠøсыŠ²Š°Ń‚ŃŒ font-family Š² HTML?

4th Aug 2018, 9:02 AM
Ibrahim
5 Answers
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