Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a div inline with <p> tag

Tags:

html

For my website, I've been wanting to add a Facebook Follow button. I want it to look something like this:

Follow us on Facebook: [THE FOLLOW BUTTON]

Note that the <p> tag and the <div> tag of the button should be inline.

I'm using the following code:

<p>Follow us on Facebook:</p><div id="follow-button"></div>

When using the code, it's not rendering properly and the Follow button is always displayed below the <p> tag

like image 602
Mihir Chaturvedi Avatar asked Mar 11 '23 09:03

Mihir Chaturvedi


2 Answers

You need to make both elements inline:

Your html:

<p> Follow us on Facebook: </p>
<div id="follow-button"> Button </div>

Your css:

p { display: inline; }
div { display: inline; }

(Note you can also set them to 'inline-block' if you want them to act like block elements)

like image 112
FDbomb Avatar answered Mar 19 '23 03:03

FDbomb


Its because <div> always take 100% width. Why don't you take <button> in place of <div>.

like image 24
rohit raut Avatar answered Mar 19 '23 02:03

rohit raut