•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 456,532 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,893 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 712 | Replies: 1
![]() |
•
•
Join Date: Oct 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
I'm making a website with the little help of my dad who’s is working in <SNIP> . It is the professional site and which site I making it is just finished up an html, xhtml, and css tutorial for review and would like to know the html code for aligning an image in the center, left, or right area of the page using css.
not enclosing it in center tags.
not enclosing it in center tags.
Last edited by happygeek : Oct 8th, 2007 at 5:43 am. Reason: URL snipped, solicitation
Unfortunately, the W3C deprecated center, and didn't give use anything that works reliably to replace it. They were thinking so much in terms of books and newspapers, that they didn't provide methods for centering things other than text.
How to align something depends on what that something is:
Text is aligned with the text-align style.
You can float anything left, right, or none with the float style, but centering is not part of float.
Most other things will center if you enclose them in a div set up as follows:
Images won't cent4er like everything else.
They took away something simple and gave us a mess.
How to align something depends on what that something is:
Text is aligned with the text-align style.
text-align: left; text-align: center; text-align: right; text-align: justified;
You can float anything left, right, or none with the float style, but centering is not part of float.
float: left;
Most other things will center if you enclose them in a div set up as follows:
<style>
cend {margin-left: auto; margin-right: auto;
border: none; padding: 0;
text-align: center;}
ceni {clear: both;}
whf {width: 50%;} // keep table from being full-width
<div class="cend">
<table class="ceni whf">
// table contents
</table>
</div>Images won't cent4er like everything else.
<style>
cenb {margin: 0; border: none; padding: 0;
text-align: center;}
ceni {clear: both;}
<div class="cenb">
<img src="myimage.jpg" class="ceni whf" />
</div>They took away something simple and gave us a mess.
Last edited by MidiMagic : Oct 8th, 2007 at 9:47 pm.
Daylight-saving time uses more gasoline
![]() |
•
•
•
•
•
•
•
•
DaniWeb HTML and CSS Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Web Developer (PHP, MySQL, HTML, CSS) Wanted in London (Web Development Job Offers)
- Part time PHP+HTML/CSS working at home (Web Development Job Offers)
- Where's the HTML and CSS forum? (DaniWeb Community Feedback)
- Web Designer HTML/CSS (Web Development Job Offers)
- Learning web design, HTML, CSS, etc... (HTML and CSS)
- Totally new to html, css questions (HTML and CSS)
Other Threads in the HTML and CSS Forum
- Previous Thread: My site looks crazy for one user
- Next Thread: Comment BOX



Linear Mode