(I already passed this section and know what to do)
However my question is why does this work? Is this just a display: inline-block ; thing? Or does this work with all < p > elements (that all < p > will be closer than usual if you put it together and not on a separate line?)
My biggest question is why does the width element move inwards but it moves outwards when it has to do with text?
Here is the code:
Every element has a “size” and behavior, inline, block; when you use the inline: block, they behave as blocks, in a line, really box after box. If you remove the flavor and price classes, you can see that they start on the left, and are all grouped one after the other.
Another thing is that the p element is by default a block-level element, which means that every p element even if on the same line, will each occupy a new line. Using the display: inline-block we avoid that.
I’m not sure what you’re asking here, if you don’t mind please ask again differently.
The width applies the size to the “block” of the element, see this image:
After making both p elements inline-blocks, we align them to the left and right, and tell them each to occupy 50% of the space available. You can see that if you remove the “align-right” and “align-left”, they will still occupy 50% of the available space, though the text will be centered in each “box”.
Yes there are quirky ways HTML handles whitespaces (this includes space , tabs and new lines) that lead to some quirky solutions. Note that this only happens in Inline element
I’m not quite sure if I get what you mean by inwards and outwards but try to tinker around with the inspect element button to see the corresponding element sizes.
You can also use outline: solid 1px black to display their bounding boxes and debug the size, margin, and widths. Outline does not add to the overall size of the element hence that is better than using border.
.item p {
display: inline-block;
outline: solid 1px black;
}
Then you can tell which is moving inwards or outwards. (i still dont know exactly what you mean by this haha)
Hope this helps, Feel free to ask us another question