user2892875
user2892875

Reputation: 89

<center> making new line

Alright so I'm trying to create a top bar line the one somewhat at the top of this one. I used the tag and when I try and put anything else on the line it goes to the next line. My code looks like this:

<div id="topbar">
    <center>
        <img src="images/hehe.png" />
    </center>
    ALSO ON TOP BAR!
</div>

but instead the image is on the top bar and "ALSO ON TOP BAR!" goes to the next line and is no longer in the top bar. How do I fix this?

Upvotes: 1

Views: 1827

Answers (3)

uberrobert
uberrobert

Reputation: 101

I would refrain from using the center tag set as it is no longer used in HTML. It's recommended to use CSS for your task.

As mentioned in another thread, text-align: center will fix your issue. However, I would recommend the following to horizontally center non-textual elements:

img {
      display: block; 
      margin: 0 auto;
}

This would center your image horizontally.

Demo: http://jsfiddle.net/uberrobert/GPGbn/1/

Upvotes: 0

LIGHT
LIGHT

Reputation: 5712

<div class="topbar">
    <div style="text-align:center;">
        <img src="images/hehe.png" />
        ALSO ON TOP BAR!
    </div>
</div>

Using css text-align:center; to centralize.

Upvotes: 0

Karuppiah RK
Karuppiah RK

Reputation: 3964

#topbar
{
    text-align: center;
}

and Html is

<div id="topbar">
<img src="images/hehe.png" />
ALSO ON TOP BAR!
</div>

Fiddle

Don't use <center> tag. mention in css stylesheets.. That is the better one..

Upvotes: 3

Related Questions