<!DOCTYPE ... line disturbs CSS interpretation

Author Message

nigel dodd

Friday 19 August 2005 4:31:43 am

I was wondering why my CSS to add a margin to the menu

div#topmenu-design
{
    margin: 0 0 0 80px;

only worked when template debugging was on. It took me a long time to see that the debugging line that affected it was the one right at the top of the html file:

<!-- START: including template: design/dd4/templates/pagelayout.tpl (design:pagelayout.tpl) -->
<p class="small">design/dd4/templates/pagelayout.tpl</p><br/>
<!DOCTYPE html PUBL........

which is really a bug because the browser cannot properly interpret any <p> before the <html> tag. (let alone the <body> tag).
Nevertheless the inclusion of this debug line right at the top of the html meant that the browser would correctly interpret the CSS for the menu margin.

Removing the line

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

from the top of pagelayout.html means everything works fine and the CSS is properly interpreted but goes against my behavioural programming which tells me to leave alone things I don't understand.

Can anyone tell me what dire consequences ensue from leaving out this line and why leaving it out causes the CSS to work properly?

bisk

Friday 19 August 2005 7:22:36 am

This is a case of quirks and standards-compliant mode.
A page with a correct doctype will be rendered by the browser in standards-compliant mode. A page with a wrong/invalid doctype (or in your example an incorrect paragraph line above the doctype) or with no doctype will be rendered by the browser in quirksmode.

In quirks mode, the browser attempts to render code based on a best-guess and in standards mode it will be rendered based on the declaration and it's standards.

So if your menu has a wrong margin in standards mode, it's either a problem with your css or it's a browser bug.

-------------------------------
http://www.kookfijn.nl & http://www.magento.be

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 18:21:41
Script start
Timing: Jan 18 2025 18:21:41
Module start 'layout'
Timing: Jan 18 2025 18:21:41
Module start 'content'
Timing: Jan 18 2025 18:21:42
Module end 'content'
Timing: Jan 18 2025 18:21:42
Script end

Main resources:

Total runtime0.8859 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 589.1797152.6406
Module start 'layout' 0.00550.0029 741.820339.4766
Module start 'content' 0.00840.8760 781.2969525.9375
Module end 'content' 0.88440.0015 1,307.23448.1250
Script end 0.8859  1,315.3594 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3535160.0002
Check MTime0.00130.1471160.0001
Mysql Total
Database connection0.00090.106910.0009
Mysqli_queries0.840894.9094540.0156
Looping result0.00050.0517520.0000
Template Total0.855496.620.4277
Template load0.00170.190220.0008
Template processing0.853796.359520.4268
Template load and register function0.00010.011710.0001
states
state_id_array0.00230.258410.0023
state_identifier_array0.00090.100420.0004
Override
Cache load0.00130.1515190.0001
Sytem overhead
Fetch class attribute can translate value0.00100.114520.0005
Fetch class attribute name0.00130.143330.0004
XML
Image XML parsing0.00070.073620.0003
class_abstraction
Instantiating content class attribute0.00000.000730.0000
General
dbfile0.00080.0906160.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs