CSS - can you set a link from the style sheet? [Solved]

For discussions about game development that does not fit in any of the other topics.
Post Reply
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

CSS - can you set a link from the style sheet? [Solved]

Post by Callan S. »

I want to set the link latter (it'll be a homepag link) and I want to use that link in multiple pages. I don't want to go back and edit all the pages. Had a quick google but didn't find any answer on this. I don't know CSS terribly well - can you set a link in the style shee so any div use of it in pages will give that same link?
Last edited by Callan S. on Mon Mar 31, 2014 5:12 am, edited 1 time in total.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS - can you set a link from the style sheet?

Post by Jackolantern »

CSS has few options for altering the content of pages, only the presentation. This would really more be in Javascript's world. Or, if you are using PHP, you could just create a PHP file that contains an array of links and other resources to be repeated over and over through your website, and include_once() the file and use the array values where needed.
The indelible lord of tl;dr
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: CSS - can you set a link from the style sheet?

Post by Callan S. »

I'm genuinely surprised! I mean I've heard people talk up CSS going 'well now you don't have to go and change 30 pages if you want to change one thing' - then it drops the ball on what is a fairly humdrum element (a homepage link)?

I was actually thinking of using include but I thought that might be the inelligant solution!

Here's a thing - from the tutes 'connect.php' is run using 'include' - could it use include_once or is it different somehow and needs to be run each time?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS - can you set a link from the style sheet?

Post by Jackolantern »

The difference is that if a file is include() more than one time in the same file, it will be reloaded. include_once() will ignore any additional includes of the same file on the same file. They are typically interchangeable, and which one you use only matters in certain circumstances.
The indelible lord of tl;dr
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: CSS - can you set a link from the style sheet?

Post by Callan S. »

Oh, so like if you used include_once for the same file on the same page, it'd ignore the second one because it had already run it once?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS - can you set a link from the style sheet?

Post by Jackolantern »

Exactly. It was added to PHP back in the day when most devs where using include() to build up templates for their site, and a lot of that including was being done programmatically.
The indelible lord of tl;dr
Post Reply

Return to “General Development”