PDA

View Full Version : Updating dates with CSS?



Titties
07-30-2006, 01:10 PM
Hi

I am currently making a website using CSS and HTML
I have made a vertical left-aligned menu, where i wish to put a "last updated: date"
It is easy enough, but when i have multiple sites, I have to change the date manually on all of the sites.

Can I somehow enter the date in the stylesheet, so when i change the date in the stylesheet, it changes on all html files?

Thank you

from Titties

Twey
07-30-2006, 03:09 PM
No.

That's not what CSS is for. :)

Titties
07-30-2006, 03:11 PM
Ok, thx

But is there any other way. For example loading an external file, so i just have to change that file?
I have tried with an iframe, but it ruins the design.. unless i can make the background see through/0% oppacity?

mburt
07-30-2006, 03:15 PM
You could use... Frames.. (flinches) The problem with frames is, that if you go to another site that uses frames from your site, the frames in your page will be stuck in the next page. Now, there's a certain way to avoid this, I'm just not sure how... :cool:

Twey
07-30-2006, 04:07 PM
The ideal way to do this is via server-side scripting. However, you can also do:
<script type="text/javascript">
document.write("Document last modified: " + document.lastModified);
</script>

mburt
07-30-2006, 04:11 PM
But you still have to add it to every page.

Twey
07-30-2006, 05:16 PM
Yes, but it's not necessary to update each page.

mburt
07-30-2006, 05:21 PM
Right.. I knew that.. lol

Titties
07-30-2006, 06:24 PM
Thank you guys

I solved it myself with the use of an iFrame including and external file I called date.html, so now i just have to change the date.html.. but if you say one might encounter errors with frames, i will certainly try to use somethings else..

but i am not sure that I understand the code Twey so kindly provided:


<script type="text/javascript">
document.write("Document last modified: " + document.lastModified);
</script>

So i just implement this on all the html sites the same place, like this (for example):

<script type="text/javascript">
document.write("Document last modified: 1st of september 2008 " + document.lastModified);
</script>
And then just change it on one of the html files and then it auto updates on the other HTMLs?

Did I get that right?

Twey
07-30-2006, 06:47 PM
No :)

You'd put the code in verbatim, and it would automatically display the last-modified time of each page. No need to worry about updating it.

Titties
07-30-2006, 07:00 PM
ahh thanks, now it works.. now I know i am being demanding, but cant i format the text, so the date and the last modified part gets these settings:



<DIV style=" font-size:0.9em;
font-family:Trebuchet MS, Verdana;
padding-left:0px;
padding-top:1px;
padding-bottom:1px;
text-align:left;">

Last modified:
Date - time
</DIV>

So I mean combine it with the script somehow?

mburt
07-30-2006, 07:04 PM
So just load it on every page, and leave it. The script itself will do the rest.

Twey
07-30-2006, 07:09 PM
<p style=" font-size:90%;
font-family:Trebuchet MS, Verdana[color=red], sans-serif[/url];
padding-left:0;
padding-top:1px;
padding-bottom:1px;
text-align:left;">
Last modified:
<script type="text/javascript">
document.write(document.lastModified);
</script>
</p>IE doesn't handle em sizes well for fonts; you should use percentages instead. You should always provide a generic font family in case the user doesn't have any of the specified fonts. Also, Verdana is a particularly bad choice for websites, since it is considerably larger than other fonts at the same point size. A paragraph element is semantically more correct here.

Titties
07-30-2006, 07:21 PM
Thank you Twey, it works now :)

And also thanks about the em vs percentages i'll change my whole stylesheet now :)

And i'll also consider revising my fonts.
What happens if a user doesnt have the current font installed? will he or she not be able to view the site then?

mburt
07-30-2006, 07:24 PM
Well, all the basic fonts most people have, and if they don't someone must have taken a sledgehammer to their hardrive :)

Titties
07-30-2006, 07:31 PM
Well, all the basic fonts most people have, and if they don't someone must have taken a sledgehammer to their hardrive :)

Haha, well i guess that couldnt be more true :D

THx for the help guys..

Now, i have your attention, would you please tell me what you think of my site?

www.titoo.dk
Not very updated, but most the design?


And the new one which i were asking the help about, which i am working on for a political youth organization

http://titties.homepage.dk

I know they look alike ;-)

Twey
07-30-2006, 07:35 PM
No, some other font (usually the system default) will be used instead. This can cause a drastic change in the "look and feel" of your page. There are four basic types of generic font face: monospace (such as Courier), sans-serif (such as Microsoft Sans), serif (such as Times New Roman), and fantasy (such as Wingdings). You should specify one of the four at the end of the list so that whatever happens, your site won't be *too* far off what it's meant to look like.
Well, all the basic fonts most people have, and if they don't someone must have taken a sledgehammer to their hardrive :)Not necessarily true. Microsoft-specific fonts, for example, are only available on Microsoft systems. The only fonts just about all modern systems have are Courier, Ariel, and Times New Roman, but even these shouldn't be relied upon totally.

The design is pretty, but: http://validator.w3.org/check?uri=http%3A%2F%2Fwww.titoo.dk%2Ffront.html&charset=%28detect+automatically%29&doctype=Inline

Titties
07-30-2006, 07:49 PM
Yea, i've seen those errors. But i dont understand them. I've tried to fix them before, but without success.
It complains about end tags and some attributes, but I can't find any mistakes when browsing through my code.

It appears to be something with the document type, but i just don't get it..

Twey
07-30-2006, 08:05 PM
It appears to be something with the document type, but i just don't get it..Hahaha, I hadn't noticed that. "XHTML 4.01 Strict?" We're not even up to XHTML 2.0 yet :p Change your DOCTYPE to a valid one, then we can have a look.

Oh, and: http://www.hixie.ch/advocacy/xhtml

Titties
07-30-2006, 08:18 PM
Ok, i've changed it to 1.0 instead of 4.01 ;)

But now there are 18 errors instead of 12, and it is the same type of errors as before, so i still dont know how to get around them

Twey
07-30-2006, 08:23 PM
Did you read the link?

For a general-purpose site, you probably shouldn't be using XHTML.

Titties
07-30-2006, 08:34 PM
I read the link.

Ahh, my bad - I didnt remove the X infront of HTML :)

But i still have 11 errors, which i cant get rid of:
http://validator.w3.org/check?uri=http%3A%2F%2Ftitties.homepage.dk%2Ffront.html


For example, howcome there are so many end tag errors? I cant find them when i read through my code.. And also; why is <centering> bad? How should i center my site then?

EDIT:

OK, i've changed DOCTYPE to frameset now. So it is down to 9 errors:
http://validator.w3.org/check?uri=http%3A%2F%2Ftitties.homepage.dk%2Ffront.html&charset=%28detect+automatically%29&doctype=Inline

Twey
07-30-2006, 09:59 PM
There's no frameset on that page. Therefore, you shouldn't use a frameset DOCTYPE. You'll never get a standard page to validate with a frameset DOCTYPE :)

You should be using strict.

With regards to the tag endings, I see plenty:
<meta name="keywords" content="konservativ ungdom, politik, roskilde" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="stylesheet.css" type="text/css" rel="stylesheet" media="screen" />This is just messed up:
<style="
font-size:90%;
font-family:Trebuchet MS, Verdana;
padding-left:0;
padding-top:1px;
padding-bottom:1px;
text-align:left;
">
Sidst opdateret:<br>
<script type="text/javascript">
document.write(document.lastModified);
</script>
</style>That's a blank tag with a style attribute. If you remove that style attribute, it parses as:
<>That's not a valid tag. Besides, <style> elements are only allowed in the <head>.

The <center> tag has been deprecated for a long time now in favour of the CSS
text-align: center; and/or
margin-left: auto; margin-right: auto;and the color for the CSS color: property.

Titties
07-31-2006, 05:34 PM
Thank you Twey; I am down to 2 errors now:

http://validator.w3.org/check?uri=http%3A%2F%2Ftitties.homepage.dk%2Ffront.html&charset=%28detect+automatically%29&doctype=Inline&ss=1

Would you be so kind to help me terminate the final 2 errors?

Twey
07-31-2006, 06:46 PM
Those are because you're using a Frameset DOCTYPE, but that page isn't a frameset :)

Titties
07-31-2006, 07:03 PM
Wee, thank you :) Now it is finally valid :o)