User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Oct 2007
Posts: 1
Reputation: Amenda is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Amenda Amenda is offline Offline
Newbie Poster

Html/Css Classes, Please Help!?

  #1  
Oct 8th, 2007
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.
Last edited by happygeek : Oct 8th, 2007 at 5:43 am. Reason: URL snipped, solicitation
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2,604
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 119
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Html/Css Classes, Please Help!?

  #2  
Oct 8th, 2007
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.
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb HTML and CSS Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 4:33 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC