Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css display:block and its opposite

Tags:

html

css

To separate one line of text onto two lines I am using:

<p>Line one <span>line two</span></p>   
p span { 
     display:block
}

But on the mobile version of my page I would like to remove that block on the element so that it displays all on one line. Is there an opposite of display:block? Am I using the correct approach to accomplish this?

like image 249
nick Avatar asked Jan 09 '14 01:01

nick


People also ask

What is the opposite of display block in CSS?

The display: inline-block Value Compared to display: block , the major difference is that display: inline-block does not add a line-break after the element, so the element can sit next to other elements.

What is the opposite of display none in CSS?

There is no opposite, they all are the opposite.

What is the opposite of block in HTML?

opposite of display block is. display : none; it used for deleting and recreating them.

What is the opposite of block code?

Inline Elements: An inline element is the opposite of the block-level element.


3 Answers

If you want them to be in one line but still blocks/boxes (so to have width and height) use this:

display:inline-block;

If you want them to be replaced as text (so as sequence of characters) then use

display:inline;

By default span elements have display:inline; styling.

like image 107
c-smile Avatar answered Oct 24 '22 17:10

c-smile


With opposite I assume you want to hide it? That'll be display: none; Making display none on the span will hide the whole line completely, though. Try it like this:

<p>Line one <br/>line two</p>   

And in the media query for mobile

p br { 
    display: none;
}
like image 24
Anthony Weber Avatar answered Oct 24 '22 15:10

Anthony Weber


The display property specifies the display behavior & visibility of an element.

opposite of display block is

display : none; 

it used for deleting and recreating them.

You can also consider inline-block :

inline-block elements inline elements but they have a width and a height.

like image 21
Arman Hakim Sagar Avatar answered Oct 24 '22 15:10

Arman Hakim Sagar