PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Aug 19, 2019 4:13 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Mar 20, 2010 10:59 pm 
Offline
Forum Regular
User avatar

Joined: Tue Sep 25, 2007 8:36 am
Posts: 521
Location: Greece
I am working in a website that will possibly require different stylesheets.

I've been using <link href> to link to different stylesheets, but lately this idea stroke me, why not turn the css file into a php document and include it inside the page using the <style> tag instead?
I thought that this would be faster as no additional requests would be made to the server for the css files and also it could have the benefit to use php tags to e.g. specify and generate a path for images like <?php echo $image_path ?>test.png

What do you think of this idea?


Top
 Profile  
 
PostPosted: Sun Mar 21, 2010 8:45 am 
Offline
Forum Newbie

Joined: Sun Mar 21, 2010 8:32 am
Posts: 5
Hi
<link href="your-style.css" rel="stylesheet" type="text/css" media="screen" />
is the best way and fasted for my website. may be different you you use an java or mysql on the page?


Top
 Profile  
 
PostPosted: Sun Mar 21, 2010 12:19 pm 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria
<link rel> requires HTTP request. On the other hand, it can be cached, and inline CSS (style) cannot. So in my opinion the best way is to have the common CSS in an external file, and the page-specific to be inline to save HTTP request, as well as loading and parsing of CSS that is not used on the specific page.


Top
 Profile  
 
PostPosted: Wed Sep 01, 2010 5:11 pm 
Offline
Forum Newbie
User avatar

Joined: Sun Jul 18, 2010 11:27 pm
Posts: 18
Use <link> for css. Make it external and make it a PHP file with the header as:

Syntax: [ Download ] [ Hide ]
 <?php header("Content-type: text/css"); ?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group