...

View Full Version : Center text - How do I go wrong?



effpeetee
05-19-2007, 10:38 AM
The following is the "style" part of my index page.
I have removed a "center" tag in order to update the page and used the entry in red to try to center the "greet" print.

It doesn't work. What am I doing wrong?

effpeetee



<style type="text/css">
h1,h2 {font-family: Arial;}
h1 {color:red}
h2,h3 {color:cyan}
h6 {color:cyan}
h5,h5 {color:white}
h6,h5,h5,h3,h2,h1,p {
margin: 0;
}
#clockbox0{
position: absolute;
left: 1em;
color:white
}

#clockbox1{
position: absolute;
right: 1em;
color:white
}

#greet{color:red;
text-align:center}

p#pc {margin-top:20px;margin-left:15px;}

</style>

<script type="text/javascript" src="include.js"></script>
<script type="text/javascript">

function greet() {
var todaydate = new Date();
var timeis = todaydate.getTime();
todaydate.setTime(timeis);
var houris = todaydate.getHours();
if (houris >17) display = "Evening";
else if (houris >11) display = "Afternoon";
else display = "Morning";
var title = document.title;
var welcome = ("Good " + display + ". Welcome to the Taylor Website");
document.write(welcome);
}
-->
</script>

</head>
<body>
/*I used to have the '<center>' tag here*/
www.exitfegs.co.uk

<div id="wrap">
<span id="clockbox0"></span><span id="clockbox1"></span><br /></div>
<h1>
<span id="greet">

_Aerospace_Eng_
05-19-2007, 10:58 AM
We need to see the rest of your html, but from the snippet you provided you aren't using the h1 element correctly. You have a span but a span will only be the width of the text in it so it will never center. If you change this

<div id="wrap">
<span id="clockbox0"></span><span id="clockbox1"></span><br /></div>
<h1>
<span id="greet">
to this

<div id="wrap">
<span id="clockbox0"></span><span id="clockbox1"></span><br /></div>
<h1 id="greet">

Your text will center. Be sure to remove the closing </span> tag. I suggest you look into the term 'html semantics' as from the code I've seen you post you really need to understand semantics. Much of your code is used in an incorrect way.

effpeetee
05-19-2007, 11:14 AM
Thank you,
The modification worked fine.
I am at the moment reading a book which is dealing with Semantics.

"Cascading Style Shets" by Owen Briggs, Steven Champeon etc.,

Obviously I have far to go. But I'll stick with it.

Kind regards,

effpeetee

www.exitfegs.co.uk



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum