Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What makes the vote buttons in StackOverflow be on different lines?

Tags:

css

The vote buttons just have an img tag, span tag, and another img tag. When I try these out in a fresh page, they come out on the same line. What CSS element exactly is causing them to be on different lines?

<img class="vote-up" width="40" height="25" title="This question is useful and clear (click again to undo)" alt="vote up" src="http://sstatic.net/so/img/vote-arrow-up.png"/>
<span class="vote-count-post" title="View upvote and downvote totals" style="cursor: pointer;"> 0 </span>
<img class="vote-down" width="40" height="25" title="This question is unclear or not useful (click again to undo)" alt="vote down" src="http://sstatic.net/so/img/vote-arrow-down.png"/>
like image 870
ripper234 Avatar asked Dec 18 '22 03:12

ripper234


2 Answers

They are applying display:block to all three items. This is important because img and span elements are inline by default, unlike p and div tags which are block elements by default.

Elements that are display:block by default take up the whole space left to right, and keep themselves on their own line as well as pushing other elements to the next line. Even if a width is applied that limits their size, they will still remain on their own line unless you change the position to absolute or float the element.

like image 67
Doug Neiner Avatar answered Mar 09 '23 01:03

Doug Neiner


display:block;

Block-level elements are those elements of the source document that are formatted visually as blocks (e.g., paragraphs). Several values of the 'display' property make an element block-level: 'block', 'list-item', and 'run-in' (part of the time; see run-in boxes), and 'table'.

Block-level elements (except for display 'table' elements, which are described in a later chapter) generate a principal block box that contains either only block boxes or only inline boxes. The principal block box establishes the containing block for descendant boxes and generated content and is also the box involved in any positioning scheme. Principal block boxes participate in a block formatting context.

http://www.w3.org/TR/CSS21/visuren.html

like image 27
meder omuraliev Avatar answered Mar 09 '23 00:03

meder omuraliev