Reputation: 4340
<div id="logo" style="center"><img src="logo1.png"></img></div><br><br><br><br><br><br><br></div>
This doesn't work. Whats the problem with the style of the div? i'm sure the syntax is wrong.
Upvotes: 0
Views: 7516
Reputation: 2748
Try this. You have to set the width of a div as shown below in order for it to work. To specify that the text inside the div is centered, simply apply style="text-align: center"
<div id="logo" style="margin-left: auto; margin-right: auto; width: 500px; border: 1px solid #ff0000">Your content here....</div>
Note: set 500px width to your desired width. Also, remove border: directive. I just added that so you could see the DIV was centered.
Upvotes: 1
Reputation: 955
Best way to center a element is probably to specify its width and put the side margin to auto:
If for example your logo1.png is 570px wide, you would do something like this in the css
#logo{
margin:0px;
margin-left:auto;
margin-right:auto;
width:570px;
}
Upvotes: 1
Reputation: 54719
"center" is not a style. You're probably looking for text-align: center
.
Images are self-closing like the line-break. You don't use </img>
.
You have a spare closing </div>
at the end of the line. One of them needs removed, I'm not sure which spot you want it in.
<div id="logo" style="text-align: center"><img src="logo1.png"></div><br><br><br><br><br><br><br>
Upvotes: 4
Reputation: 671
you cannot define style in div like that instead you can define the div property in css and call the class or id of the css.
Upvotes: 2