...

View Full Version : Echoing styled divs



tkm76
04-07-2011, 03:22 PM
I'm trying to echo div tags externally styled, but for some reason they're not doing the job.
Can anyone clarify for me what been done wrong in my code? The index.php is in the same folder as style.css
So I really don't know what more I can do to get it to work.

Thanks!



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="#" />
<meta name="description" content="#" />
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Untitled Document</title>
</head>
<body>
<div id="wrapper">123</div>
</body>
</html>
<?php

echo "<div id='wrapper'>abc</div>";

?>



style.css

// stylesheet content

#wrapper {
color: red;
border: 1px solid red;
}

angst
04-07-2011, 03:52 PM
i don't see any issue here, what exactly is the problem? is the second div in the echo not getting styled?

oesxyl
04-07-2011, 03:55 PM
I'm trying to echo div tags externally styled, but for some reason they're not doing the job.
Can anyone clarify for me what been done wrong in my code? The index.php is in the same folder as style.css
So I really don't know what more I can do to get it to work.

Thanks!



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="#" />
<meta name="description" content="#" />
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Untitled Document</title>
</head>
<body>
<div id="wrapper">123</div>
</body>
</html>
<?php

echo "<div id='wrapper'>abc</div>";

?>



style.css

// stylesheet content

#wrapper {
color: red;
border: 1px solid red;
}
your echo output the content after the document is closed using </html>

best regards

Fou-Lu
04-07-2011, 03:57 PM
Id's should not be replicated. You need to use class when you want multiple tags to apply similar styles, although best I know the actual CSS should still apply.

As this is currently sitting, this is not a problem with PHP. If the echo itself is not showing up, that would be a PHP problem, but if the tag is there and the style is not applied that is an HTML/CSS issue, not PHP. I'll await the OP to reply with whether this echo is not being produced.

angst
04-07-2011, 03:57 PM
your echo output the content after the document is closed using </html>

best regards

yes but in most browser that won't make any difference. just tested in google chrome and the styling works fine after the body/html tags are closed.

tkm76
04-07-2011, 04:00 PM
i don't see any issue here, what exactly is the problem? is the second div in the echo not getting styled?

Yes.
The fonts are default black.
Should be red.

oesxyl
04-07-2011, 04:01 PM
yes but in most browser that won't make any difference. just tested in google chrome and the styling works fine after the body/html tags are closed.
that means chrome is a garbage, :) first is the end of the document, second op use same id for both divs.

best regards

Fou-Lu
04-07-2011, 04:01 PM
Since the div is echoing, this is not a PHP issue.
Moving from PHP to html/css. What you should double check is that the html source does not include the <?php echo within it, otherwise it is improperly interpreting the entire tag (which also means you do not have PHP installed).

angst
04-07-2011, 04:01 PM
strange, it works fine here, it will likely depend on the browser your using. however as Fou-Lu mentioned, this is not a php issue. it's a css issue: http://www.codingforums.com/forumdisplay.php?f=13

tkm76
04-07-2011, 04:03 PM
Id's should not be replicated. You need to use class when you want multiple tags to apply similar styles, although best I know the actual CSS should still apply.

As this is currently sitting, this is not a problem with PHP. If the echo itself is not showing up, that would be a PHP problem, but if the tag is there and the style is not applied that is an HTML/CSS issue, not PHP. I'll await the OP to reply with whether this echo is not being produced.

I'm getting my echos, but they're not styled at all : (

So, I tried ending html like this as suggested :

?>
</body>
</html>

PHP inside html, but it changed nothing.
I'm using Firefox 4, just for the record...

oesxyl
04-07-2011, 04:06 PM
I'm getting my echos, but they're not styled at all : (

So, I tried ending html like this as suggested :

?>
</body>
</html>

PHP inside html, but it changed nothing.
I'm using Firefox 4, just for the record...
now change one of the id because must be uniq, :)

except that echo, this is a html proble, why is not in the mysql forum, :)
best regards

angst
04-07-2011, 04:06 PM
that means chrome is a garbage, :) first is the end of the document, second op use same id for both divs.

best regards

well i guess firefox is garbage too, because it also works there :rolleyes:

oesxyl
04-07-2011, 04:08 PM
well i guess firefox is garbage too, because it also works there :rolleyes:
i'm prefectly agree with you, :)

best regards

tkm76
04-07-2011, 04:17 PM
now change one of the id because must be uniq, :)

except that echo, this is a html proble, why is not in the mysql forum, :)
best regards

I didn't realize it was a html problem..
My apologies.

_Aerospace_Eng_
04-07-2011, 04:24 PM
There is a space at the end of the id in the div that is echoed.

oesxyl
04-07-2011, 04:30 PM
I didn't realize it was a html problem..
My apologies.
you don't need to apologies.
intention was to be a joke about the situation, my apologies for this.

best regards

tkm76
04-07-2011, 04:48 PM
There seems to be a problem with css file.
I tested these files outside my xampp.

It works as index.html, but when I use it at location xampp/http docs/new folder
it does not style anything.

oesxyl
04-07-2011, 04:55 PM
There seems to be a problem with css file.
I tested these files outside my xampp.

It works as index.html, but when I use it at location xampp/http docs/new folder
it does not style anything.
this is a guess, check file permission to be readable for all, could be a problem after upload.

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum