Inline Elements
Inline elements are meant for parts of a text. They sit in a line among the words, and they are exactly as wide and as tall as their content. That is why the properties width and height have no effect on them, and neither do their top and bottom margins. Margins on the left and right work as usual.
Images are an exception. You may have noticed that width worked on the photo even while it was inline. Images are so-called replaced elements: their content comes from outside the page (from the image file), and the browser sizes them like boxes, even when they are inline.
HTML also has an inline element without any meaning of its own: span. It's the inline counterpart of div. We use it to wrap a part of a text that we want to style:
<p>Price: <span class="price">$10</span></p>With display: inline, we can turn a block element into an inline one. This is how a simple menu is made: list items (li) are normally stacked below each other, but when they are inline, they line up in a row like words.
List items actually have a special value of display by default: list-item. They behave like blocks, but with a bullet. When we make them inline, the bullets disappear.
Instructions
- 1
Create a rule for
nav lithat setsdisplay: inline. The links in the navigation line up in a row. Only the items of the navigation should change; the list of breeds stays as it is. - 2
The links are too close to each other. In the rule for
nav li, addmargin-right: 20px. Left and right margins work on inline elements, so the links move apart.