/    Sign up×
Community /Pin to ProfileBookmark

Getting SPAN’s to center…

Well, I’m trying to set up some spans, mostly in order to get a better grip on my code. Namely, I’m still learning, and I like to know when something’s on the screen due to my putting it there, not just because what it’s attached to put it there.

But anyway, the short of it is thus: When I put a TEXT-ALIGN:CENTER; into a heading (on my css sheet), it centers. Which is good. I put the exact same into a span class on the same sheet, it does… nothing. I’ve even run it through the validator on the w3c site, and it says everything’s good and even lists it as a valid part of the code on my sheet.

[code]
H1 {
font-size : 28pt;
color : #000000;
text-align : center;
font-weight : 800;
line-height : 22px;
}
.TTL1 {
font-size : 28pt;
color : #000000;
text-align : center;
font-weight : 800;
line-height : 22px;
}
[/code]

The H1 is, well, a heading. The .TTL1 is the class I’m using in a span. The section of the page these refer to is as follows:
(omited code above this point)

[code]
<BODY>
<H1>Test H1</H1>
<SPAN CLASS=”TTL1″>Test TTL1</SPAN>
[/code]

(and omitted the rest of the code after this point, although to my knowledge none outside this should affect it. The header contains the import link to get the css, no other style code.)

Anyway, if anyone can help with this, it’d be much appreciated.

Thanks.

Z

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 07.2006 — Span is, by default, an in-line element. Therefore, text-align won't affect it. If you want the contents of the span to be a stand-alone block of text (centered or not), then it would make more sense to use an appropriate block-level element, such as <p>. If there is some semantic reason to use a <span> that you want to be treated as a block-level element, then add [b]display: block;[/b] to the style for that element. But at least for your above example using a <p> would make more sense.
Copy linkTweet thisAlerts:
@ZitchasauthorJan 07.2006 — Well, I did as sugested, and now it works.

Once again, thank you for the help. It seems I still have much to learn about using all these.

Thanks
Copy linkTweet thisAlerts:
@NogDogJan 07.2006 — [url=http://www.w3.org/TR/CSS21/propidx.html]This chart[/url] can be useful for a quick reference to see if a property has limited applicability.
Copy linkTweet thisAlerts:
@ray326Jan 07.2006 — Since your content is senseless it's impossible to make a correct recommendation but that probably shouldn't be marked as a span at all. It probably should be a heading, paragraph or list item, all of which are block elements to which text-align:center can be applied.
×

Success!

Help @Zitchas spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...