Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > CSS will not center

Reply
Thread Tools

CSS will not center

 
 
alice
Guest
Posts: n/a
 
      07-21-2007
Can someone tell me why, or for that matter how it's even possible,
that text placed between this span with this class would not be
centered?

..heading {
font: small-caps normal 18px Georgia, "Times New Roman", Times,
serif;
text-transform: uppercase;
text-decoration: underline;
padding: 8px;
background: #232323;
text-align: center;
clear: both;
margin-right: auto;
margin-left: auto; }

All the other attributes are working, like the font and background.
What am I doing wrong? I've tried adding the inline style="text-
align:center" and that will not do anything either. I've tried it
without the left and right auto margins as well.

 
Reply With Quote
 
 
 
 
Benjamin Sattler
Guest
Posts: n/a
 
      07-21-2007
Hi!

I guess you will have to make this span a block-level element. span
is an inline element. If you do then you should also specify a
width as otherwise the element streches across the whole screen
(the width of its parent container-element, respectively):

display:block;
width:100px;

Alternatively you may drop the "display" rule and just replace span
with a div element, which works the same way like span except it
already is a block level element.

bye

alice <(E-Mail Removed)> wrote:

> Can someone tell me why, or for that matter how it's even
> possible, that text placed between this span with this class
> would not be centered?
>
> .heading {
> font: small-caps normal 18px Georgia, "Times New Roman",
> Times,
> serif;
> text-transform: uppercase;
> text-decoration: underline;
> padding: 8px;
> background: #232323;
> text-align: center;
> clear: both;
> margin-right: auto;
> margin-left: auto; }
>
> All the other attributes are working, like the font and
> background. What am I doing wrong? I've tried adding the inline
> style="text- align:center" and that will not do anything either.
> I've tried it without the left and right auto margins as well.
>
>


 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      07-21-2007
Scripsit alice:

> Can someone tell me why, or for that matter how it's even possible,
> that text placed between this span with this class would not be
> centered?


The text-align property applies to block elements only. You could set
display: block, but...

> .heading {


.... since you really seem to have a heading, please read a good book on web
design, in order to get cured from SPANitis and DIVitis. When you then use
proper markup, such as <h1>...</h1> for the main heading, the problem
vanishes in a puff of logic (as a side effect, since h1 is block level by
default).

> font: small-caps normal 18px Georgia, "Times New Roman", Times,
> serif;


Did you know that browsers don't really use small-caps? They just fake it by
changing font size, making typographers aggravated.

The good book on web design will tell you why px is a wrong unit for
font-size. Use something like font-size: 140% instead.

> text-transform: uppercase;


Did you know that all-uppercase text is less readable and often ignored as
SHOUTING?

> text-decoration: underline;


The good book will tell you why should not underline anything that is not a
link.

> background: #232323;


What happens when the text color is #232323? Hint: It could be. You are
apparently not doing anything to prevent that.

> margin-right: auto;
> margin-left: auto; }


Horizontal margins have no effect on non-replaced inline elements, by CSS
specs.

> All the other attributes are working,


They are not attributes, and they mostly "work" for some odd values for
"work" only.

> What am I doing wrong?


To be honest, in this case, pretty much everything*). But it's curable.
There are many good books on web design. Hanging around in Usenet groups may
help a little, too.

*) However, the problem you regard as problem is easily fixable, as
mentioned. It's actually one of the _small_ problems.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      07-22-2007
Well bust mah britches and call me cheeky, on Sat, 21 Jul 2007 20:12:08 GMT
Benjamin Sattler scribed:

> Hi!
>
> I guess you will have to make this span a block-level element. span
> is an inline element. If you do then you should also specify a
> width as otherwise the element streches across the whole screen
> (the width of its parent container-element, respectively):
>
> display:block;
> width:100px;
>
> Alternatively you may drop the "display" rule and just replace span
> with a div element, which works the same way like span except it
> already is a block level element.
>
> bye


Nice x-face, Benny. But are you really as smart as you look? Top-posting
suggests a contrary answer.

--
Neredbojias
Half lies are worth twice as much as little fibs.
 
Reply With Quote
 
Benjamin Sattler
Guest
Posts: n/a
 
      07-22-2007
Neredbojias <(E-Mail Removed)> wrote:

> Well bust mah britches and call me cheeky, on Sat, 21 Jul 2007
> 20:12:08 GMT Benjamin Sattler scribed:
>
> Nice x-face, Benny. But are you really as smart as you look?
> Top-posting suggests a contrary answer.
>


hrmpf... I will try and do better... Definitely
 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      07-22-2007
Well bust mah britches and call me cheeky, on Sun, 22 Jul 2007 09:55:19 GMT
Benjamin Sattler scribed:

> Neredbojias <(E-Mail Removed)> wrote:
>
>> Well bust mah britches and call me cheeky, on Sat, 21 Jul 2007
>> 20:12:08 GMT Benjamin Sattler scribed:
>>
>> Nice x-face, Benny. But are you really as smart as you look?
>> Top-posting suggests a contrary answer.
>>

>
> hrmpf... I will try and do better... Definitely


Sorry, I'm just a natural-born smart-ass. Too old to change now. (But
Duende is the _official_ group geezer.)

--
Neredbojias
Half lies are worth twice as much as whole lies.
 
Reply With Quote
 
Duende
Guest
Posts: n/a
 
      07-22-2007
On 22 Jul 2007 Neredbojias wrote in alt.html

> Well bust mah britches and call me cheeky, on Sun, 22 Jul 2007 09:55:19
> GMT Benjamin Sattler scribed:
>
>> Neredbojias <(E-Mail Removed)> wrote:
>>
>>> Well bust mah britches and call me cheeky, on Sat, 21 Jul 2007
>>> 20:12:08 GMT Benjamin Sattler scribed:
>>>
>>> Nice x-face, Benny. But are you really as smart as you look?
>>> Top-posting suggests a contrary answer.
>>>

>>
>> hrmpf... I will try and do better... Definitely

>
> Sorry, I'm just a natural-born smart-ass. Too old to change now. (But
> Duende is the _official_ group geezer.)
>


More like wheezer.



--
D?
 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      07-23-2007
Well bust mah britches and call me cheeky, on Sun, 22 Jul 2007 18:19:17 GMT
Duende scribed:

>>>> Nice x-face, Benny. But are you really as smart as you look?
>>>> Top-posting suggests a contrary answer.
>>>>
>>>
>>> hrmpf... I will try and do better... Definitely

>>
>> Sorry, I'm just a natural-born smart-ass. Too old to change now. (But
>> Duende is the _official_ group geezer.)
>>

>
> More like wheezer.


Breathing problems? Ah, am there, doin' that. Azma, emfizzeema, cope, you
name it. I got more inhalers than topless dancers have g-strings.
'Course, there _is_ a bright side. "What is it?" says you. "Well, let me
tell ya," says I. Provides a good excuse for those pesky feelings of self-
recrimination. Lack of oxygen to the brain and all that...

What happened to Puddin' Pete? Didn't set right with you? (Nyuk, nyuk.)

Btw, did you see that new Australian TSA stamp? -A philatelist's dream.

http://tinyurl.com/yuyzdr

....Heard they're gonna issue a whole series. Just can't wait to collect
'em.

--
Neredbojias
Half lies are worth twice as much as whole lies.
 
Reply With Quote
 
Yorkshire Pete
Guest
Posts: n/a
 
      07-23-2007
On 22 Jul 2007 Neredbojias wrote in alt.html

> What happened to Puddin' Pete? Didn't set right with you? (Nyuk, nyuk.)
>
> Btw, did you see that new Australian TSA stamp? -A philatelist's dream.
>
> http://tinyurl.com/yuyzdr
>


How cool, brucie on a stamp.

--
D?
Yorkshire Pete
http://yorkshirepete.com/
 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      07-24-2007
Well bust mah britches and call me cheeky, on Mon, 23 Jul 2007 17:58:42
GMT Yorkshire Pete scribed:

> On 22 Jul 2007 Neredbojias wrote in alt.html
>
>> What happened to Puddin' Pete? Didn't set right with you? (Nyuk,
>> nyuk.)
>>
>> Btw, did you see that new Australian TSA stamp? -A philatelist's
>> dream.
>>
>> http://tinyurl.com/yuyzdr
>>

>
> How cool, brucie on a stamp.


Brucie? Nah, think more schizophrenic.

--
Neredbojias
Half lies are worth twice as much as whole lies.
 
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
CSS and center align shank HTML 7 12-30-2008 08:54 AM
Naming of core NASA center with the words "Mission Control Center" & mass use of religious anthem sounding word "Mission" in Context of Space Exploration & the Moon Landing Hoax moonlandinghoaxreligious@yahoo.com Digital Photography 0 09-27-2005 08:28 PM
Center Box with CSS Quijote HTML 2 05-08-2004 06:18 PM
How do I use CSS to center child elements? Joshua Beall HTML 9 11-01-2003 08:33 AM
Re: [css] center brucie HTML 0 06-22-2003 08:08 PM



Advertisments