Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Trying to center align

Reply
Thread Tools

Trying to center align

 
 
paul j
Guest
Posts: n/a
 
      12-21-2004
I had <div align="center"> around all of my content but just found out
that's deprecated.

So I tried the following:

#container {
margin: auto ;
}

with:

<div id="container">

But it isn't centered. What am I doing wrong?

Also, what is the difference between using ".", "#" and no character next
to each CSS element?
--
Up from Third Base to Huntington
They sang another victory song...........
 
Reply With Quote
 
 
 
 
Bernhard Sturm
Guest
Posts: n/a
 
      12-21-2004


paul j schrieb:
> I had <div align="center"> around all of my content but just found out
> that's deprecated.
>
> So I tried the following:
>
> #container {
> margin: auto ;
> }
>
> with:
>
> <div id="container">
>
> But it isn't centered. What am I doing wrong?


you need to define which margin you want to center
there are very good resources out there. check out:

http://www.porjes.com/center.html

(I googled a bit to find this.. it's just one of the many examples out
there
BTW: CSS vertical centering is not quite easy to achieve

>
> Also, what is the difference between using ".", "#" and no character next
> to each CSS element?


.. refers to a class of a CSS rule. classes can be used as many time in
your document.
# refers to an ID of a CSS rule. IDs can be used only once in your document.

HTH

bernhard
---
www.daszeichen.ch
remove nixspam to reply

 
Reply With Quote
 
 
 
 
Richard
Guest
Posts: n/a
 
      12-21-2004
paul j wrote:

> I had <div align="center"> around all of my content but just found out
> that's deprecated.


> So I tried the following:


> #container {
> margin: auto ;
> }


> with:


> <div id="container">


> But it isn't centered. What am I doing wrong?


> Also, what is the difference between using ".", "#" and no character next
> to each CSS element?
> --
> Up from Third Base to Huntington
> They sang another victory song...........



div.master
div#master

<div class="master">
<div id="master">
The period designates a class while the # designates an "ID".
Both may be used, but an "ID" can only be used once within the document.
If you need to use the same styled division several times, use class.

Now investigate what padding does to content.



 
Reply With Quote
 
Oli Filth
Guest
Posts: n/a
 
      12-21-2004
DIV.container
{
text-align: center;
}

should do the trick.

Oli

paul j wrote:
> I had <div align="center"> around all of my content but just found out
> that's deprecated.
>
> So I tried the following:
>
> #container {
> margin: auto ;
> }
>
> with:
>
> <div id="container">
>
> But it isn't centered. What am I doing wrong?
>
> Also, what is the difference between using ".", "#" and no character next
> to each CSS element?

 
Reply With Quote
 
Leif K-Brooks
Guest
Posts: n/a
 
      12-21-2004
paul j wrote:
> I had <div align="center"> around all of my content but just found out
> that's deprecated.
>
> So I tried the following:
>
> [...]
>
> But it isn't centered. What am I doing wrong?


See <URL:http://dorward.me.uk/www/centre/>.

> Also, what is the difference between using ".", "#" and no character next
> to each CSS element?


With CSS, this:

p {
color : red;
}

Will turn all of these elements red:

<p>I'm red!</p>
<p class="foo">AOL: Me too!</p>
<p id="bar">Red is a nice color!</p>

But not these:

<div>I want to be red!</div>
<div class="bar">Aww, why do I have to be the stupid default color?!</div>

Whereas this:

..foo {
color : green;
}

Will turn these elements green:

<div class="foo">I'm green!</div>
<p class="foo">Green eggs and ham!</p>

But not these:

<p class="bar">I'm... not... green with envy!</p>
<div>Aww, I want to be green!</div>

This CSS:

#foo {
color : blue;
}

Will turn this element blue:

<p id="foo">No one else is blue too!</p>

But not these:

<p id="bar">No blue for me!</p>
<p>Ditto!</p>

So what's the difference between using an ID and using a class? The same
class can be used multiple times in a document (so you can have more
than one <p class="foo"> element in the same document), but IDs are
unique within a given document. An ID can also be used to identify
elements for things besides stylesheets (scripts, fragment identifiers,
etc.), whereas classes are pretty much only used for CSS.
 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      12-21-2004
Oli Filth wrote:

> DIV.container
> {
> text-align: center;
> }


> should do the trick.


It's been deprecated. Please keep up with the changes.


 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      12-21-2004
Leif K-Brooks wrote nothing intelligent:

Someone needs more eggnogg for better comprehension.
Either that , or you've had to much.
Wanna pass some around?


 
Reply With Quote
 
Neal
Guest
Posts: n/a
 
      12-21-2004
On Tue, 21 Dec 2004 15:32:24 -0600, Richard <Anonymous@127.001> wrote:

> Oli Filth wrote:
>
>> DIV.container
>> {
>> text-align: center;
>> }

>
>> should do the trick.

>
> It's been deprecated. Please keep up with the changes.


See <http://www.w3.org/TR/CSS21/text.html#propdef-text-align> please and
show us where this is deprecated.
 
Reply With Quote
 
Neal
Guest
Posts: n/a
 
      12-21-2004
On Tue, 21 Dec 2004 15:34:30 -0600, Richard <Anonymous@127.001> wrote:

> Leif K-Brooks wrote nothing intelligent:


Huh?

Leif gave a thorough discussion of how classes and ids work, and a link
for centering help. I think his reply was very well thought out.

> Someone needs more eggnogg for better comprehension.
> Either that , or you've had to much.
> Wanna pass some around?


You may not have any of my eggnog.

 
Reply With Quote
 
Oli Filth
Guest
Posts: n/a
 
      12-21-2004
Richard wrote:
> Oli Filth wrote:
>
>
>>DIV.container
>>{
>> text-align: center;
>>}

>
>
>>should do the trick.

>
>
> It's been deprecated. Please keep up with the changes.
>
>


Where does it say that? Not in the W3C's CSS 2.1 spec, anyhow. So as far
as I'm aware, I am keeping up with the changes.

Oli
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<div align=center> also affects align of dynamic dropdown item text Steve Richter ASP .Net 1 06-24-2007 07:11 PM
left align within centre align Paul Lautman HTML 3 03-03-2006 02:45 PM
text-align vs align tshad HTML 1 06-23-2005 10:29 PM
Question: TextBox - Can't Align Center VB Programmer ASP .Net 3 08-27-2003 07:49 PM
how to Align text left & vertical align middle Kay ASP .Net 2 07-25-2003 08:32 AM



Advertisments