Jump to content

Recommended Posts

I want to use css and PHP together

 

Let say I have simple PHP page:

<html> <head>
<title>Coupon Sample </title> </head>
<body>

<div id="test">
<?php
echo ("Test"); 
?>
</div>
</body></html>

Now if I want to add css to this I have two options

1. add css code in head tag

2. add external css file with <link> tag

 

My simple css is

#test
{
color:orange;
}

if I am using first option like

<html> <head>
<title>Coupon Sample </title> 

#test
{
color:orange;
}
</head>

Its working fine, for second option

<title>Coupon Sample </title>
<link rel="stylesheet" type="type/css" href="simple.css"/>
</head>

where simple.css contain css code

but its not working.. it shows text in black color instead of orange

 

Does anyone has idea about it. or is their other way to add css in this situation.

 

Thanks in advance

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/249403-css-not-working-with-php/
Share on other sites

This is not a PHP issue by any means, nor is it really a CSS issue. But PHP is completely irrelevant.

 

Your problem is in your HTML link tag within the type attribute.  It should be:

 

type="text/css"

 

Also, there is no need for the braces after an echo statement, as it is not a function, but rather a language construct.

Also, there is no need for the braces after an echo statement, as it is not a function, but rather a language construct.

 

*premiso shrugs

 

Don't really see how that is relevant here but good information (I guess). But either or, the braces or no braces it will echo out fine, more of a personal preference. :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.