Home » HTML » HTML_Page2 » Bug #5177
CSS declarations and CSS stylesheets should be rendered in the given order
Details
| Request #5177 | CSS declarations and CSS stylesheets should be rendered in the given order |
|---|---|
| Submitted | 2005-08-22 21:55 UTC |
| From | malbe at adinet dot com dot uy |
| Status | Wont fix |
| Package | HTML_Page2 |
| PHP Version | 4.3.10 |
| OS | Linux 2.4.26 |
| Roadmaps | (Not assigned) |
Comments
[2005-08-22 21:55 UTC] malbe at adinet dot com dot uy
Description:
------------
HTML_Page2 version: 0.5.0beta
To be more clear, let me define two terms first:
- style declaration: css style added using
"HTML_Page2::addStyleDeclaration()"
- stylesheet: css file added using
"HTML_Page2::addStyleSheet()"
Now, to the "bug":
To follow the real spirit of CSS, stylesheets and style declarations should be rendered inside the <head> in the order that the programmer adds them, instead of adding all the stylesheets first and then the style declarations.
The problem with the current method is that if you want to overwrite some properties of a style declaration with a stylesheet, you simply can't, because your stylesheet will always appear before the styel declaration, thus giving exactly the opposite result than the expected (the style properties in the stylesheet are overwritten with the ones in the style declaration)
Test script:
---------------
<?php
require_once 'HTML/Page2.php';
$some_css_declaration = 'html, body { background-color: #EEE; }';
$p = new HTML_Page2();
// add a declaration with a grey background
$p->addStyleDeclaration($some_css_declaration);
// try to overwrite background-color property of the html, body selectors
// using the ones in this stylesheet
$p->addStyleSheet('http://www.w3.org/StyleSheets/home.css');
// add some content...
$p->addBodyContent('The background should be white, as declared in the StyleSheet, but it\'s grey, as specified in the $some_css_declaration style declaration');
$p->display();
?>
Expected result:
----------------
The page's body background should be white
Actual result:
--------------
The background appears grey (Due to the fact that the order in which the stylesheets and declarations appear in the <head> isn't the same order in which they were added)
[2006-11-01 05:19 UTC] iwarner at php dot net
To override a style declaration with a style sheet seems an odd way to do things. You obviously have control over the declarations and so should try to minimise this output within your code.
The usual method it to overwrite a style sheet with a declaration, which works fine as you have experienced with the all grey.
Please provide a real world scenario of why you want to do this, so we can further understand then we will look into it.