#2
<div style="align-right:auto; align-left:auto;">


content


</div>
Sell and Promote your music TuneHub!



wy is yer mad at muy gramhar fer?


Quote by jimmyled
jimmybanks youre a genius.


aparently i ar smrt?
Quote by dyingLeper
jimmybanks youre a genius


GO SENS GO
#3
Using margin:auto should do the trick.
Last edited by creelers at Oct 8, 2011,
#4
Quote by JimmyBanks6
<div style="align-right:auto; align-left:auto;">


content


</div>



Try to avoid HTML-styling like that and do it propperly with CSS, it will be easier in the long run..

And normally you would use a margin adjustment to do such

HTML:
<div id="trololo">
Whateverevere content
</div><!-- trololo -->

CSS:

#trololo{
margin: 0 auto;
width: 9001px;
}

The 0 is the top margin, and the auto is the right one, which set to auto will attempt to find the middle.

Note: Using this method you must remember to align a width to your element too

Have fun
Incarnation of awesomeness on earth.
#5
Quote by ROHG
Try to avoid HTML-styling like that and do it propperly with CSS, it will be easier in the long run..

And normally you would use a margin adjustment to do such

HTML:
<div id="trololo">
Whateverevere content
</div><!-- trololo -->

CSS:

#trololo{
margin: 0 auto;
width: 9001px;
}

The 0 is the top margin, and the auto is the right one, which set to auto will attempt to find the middle.

Note: Using this method you must remember to align a width to your element too

Have fun



he asked for the HTML code not for the CSS.

Neither makes a difference in efficiency as far as i was aware anyway??
Sell and Promote your music TuneHub!



wy is yer mad at muy gramhar fer?


Quote by jimmyled
jimmybanks youre a genius.


aparently i ar smrt?
Quote by dyingLeper
jimmybanks youre a genius


GO SENS GO
#6
Quote by ROHG
Try to avoid HTML-styling like that and do it propperly with CSS, it will be easier in the long run..

And normally you would use a margin adjustment to do such

HTML:
<div id="trololo">
Whateverevere content
</div><!-- trololo -->

CSS:

#trololo{
margin: 0 auto;
width: 9001px;
}

The 0 is the top margin, and the auto is the right one, which set to auto will attempt to find the middle.

Note: Using this method you must remember to align a width to your element too

Have fun


There's nothing wrong with inline styling. I'd only use it though on one off occasions though.

Also, margin: 0 auto will set the margin as 0 for top and bottom and auto for right and left.
#7
None of the above work. Use this:

<div style="position: absolute; margin-left: -250px; left: 50%;">

<img src="./images/your_image.jpg" alt="your text" />

</div>
Instead of "-250px" put the half of the width of your image. I assumed it was 500px.
Last edited by Poglia at Oct 8, 2011,
#8
Inlinestyling sucks in increadibly many cases...

I threw in an ID example, but if he would use a center aligning as a class, he would be able to class asign it on every element he needed to have that, and wouldn't have to hardcode everything...

Problem is if he ended up having just a few elements hardcoded in his HTML, and he then needed to edit them, it starts to take quite a lot of time, in stead of just editing in your CSS one single place
Incarnation of awesomeness on earth.
#9
Quote by Poglia
None of the above work. Use this:

<div style="position: absolute; margin-left: -250px; left: 50%;">

<img src="./images/your_image.jpg" alt="your text" />

</div>
Instead of "-250px" put the half of the weight of your image. I assumed it was 500px.

...the above most definitely work, i use them on my website im coding....
Sell and Promote your music TuneHub!



wy is yer mad at muy gramhar fer?


Quote by jimmyled
jimmybanks youre a genius.


aparently i ar smrt?
Quote by dyingLeper
jimmybanks youre a genius


GO SENS GO
#10
Quote by ROHG
Inlinestyling sucks in increadibly many cases...

I threw in an ID example, but if he would use a center aligning as a class, he would be able to class asign it on every element he needed to have that, and wouldn't have to hardcode everything...

Problem is if he ended up having just a few elements hardcoded in his HTML, and he then needed to edit them, it starts to take quite a lot of time, in stead of just editing in your CSS one single place


Well yeah, of course.
Sell and Promote your music TuneHub!



wy is yer mad at muy gramhar fer?


Quote by jimmyled
jimmybanks youre a genius.


aparently i ar smrt?
Quote by dyingLeper
jimmybanks youre a genius


GO SENS GO
#11
Quote by JimmyBanks6
...the above most definitely work, i use them on my website im coding....
It does not. I knew it before trying (been coding websites for 10 years), but I tried anyway. What browser are you using?
#12
By the way, here's the simple, pure HTML version:

<center>

<img src="./images/your_image.jpg" alt="your text" />

</center>
#13
Quote by Poglia
None of the above work. Use this:

<div style="position: absolute; margin-left: -250px; left: 50%;">

<img src="./images/your_image.jpg" alt="your text" />

</div>
Instead of "-250px" put the half of the weight of your image. I assumed it was 500px.


margin:auto; will work. I use it in my container for any website I make.
#14
Quote by Poglia
It does not. I knew it before trying (been coding websites for 10 years), but I tried anyway. What browser are you using?


#headercontainer{
height: 41px;
width:975px;
margin-left:auto;
margin-right:auto;
text-color: #c3c3c3;
}


is holding my header directly centered in IE and webkit browsers
Sell and Promote your music TuneHub!



wy is yer mad at muy gramhar fer?


Quote by jimmyled
jimmybanks youre a genius.


aparently i ar smrt?
Quote by dyingLeper
jimmybanks youre a genius


GO SENS GO
Last edited by JimmyBanks6 at Oct 8, 2011,
#15
Quote by JimmyBanks6
#headercontainer{
height: 41px;
width:975px;
margin-left:auto;
margin-right:auto;
text-color: #c3c3c3
}


is holding my header directly centered in IE and webkit browsers
It doesn't work in Firefox 7. The browser reads "margin-left: auto" and makes a 50% margin. My resolution width is 1650 px so it makes a 825 margin, then the image, then the space left on the right is less than 825 pixels.
#16
Quote by Poglia
It doesn't work in Firefox 7. The browser reads "margin-left: auto" and makes a 50% margin. My resolution width is 1650 px so it makes a 825 margin, then the image, then the space left on the right is less than 825 pixels.

i honestly fight more with problems in FF than i do with IE


and on my monitor it looks fine centered, although my monitor is 1366px width


e/ it is most definitely not splitting it at 50% and leaving the content on the right. it is centered.
Sell and Promote your music TuneHub!



wy is yer mad at muy gramhar fer?


Quote by jimmyled
jimmybanks youre a genius.


aparently i ar smrt?
Quote by dyingLeper
jimmybanks youre a genius


GO SENS GO
Last edited by JimmyBanks6 at Oct 8, 2011,
#17
Externally styled CSS-driven HTML is immensely better. HTML is such a retarded markup language to begin with that we needed CSS to efficiently create changes in style without changes in structure or content. Then we needed JavaScript as a hack for better client-side functionality. Now the entire world runs on retardation and hacks and creates entire careers in product development, testing, and scalability, based on said retardation.
Quote by denizenz
I'll logic you right in the thyroid.

Art & Lutherie