Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

How to centre a div or a picture on every browser

hello, How do i center a div or a picture on every browser?

(eg)

I have a web site. I want two images that are centred in the body and to be centred on every browser size.

Is there any way this can be done?

Thanks

2 Answers

set the style to

{ width:whatever you want; margin:0 auto; }

Thanks for the reply

I have tried that but i need width 100%

i have also tried on one div margin-right:25em; and margin-left-25em. But on my bros monitor its sill not centred

any idea?

Thanks

Thanks for the reply

I have tried that but i need width 100%

i have also tried on one div margin-right:25em; and margin-left-25em. But on my bros monitor its sill not centred

any idea?

Thanks