![]() |
CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With Valid DOCTYPE.
Hi Folks:
Developing on my Solaris system. Long ago, in another century, I was a moderately competent HTML novice. I'm attempting to get up to speed with the HTML Dog tutorial. When I'm finished with that I'm planning on moving to W3 School. Any suggestions for a different approach or recommendations for a tutorial? I was attempting to get external CSS working. I was happy with my progress, until I realized that I had a typo in my DOCTYPE statement. This is the DOCTYPE for the page that has a working CSS: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> The second line starts with an angle bracket where a quote is needed. The page displays as I would hope the CSS would influence it. Correcting the DOCTYPE typo seems to cause the CSS to be ignored and the text to be displayed in the default colors. W3C Markup Validation Service complains about the invalid "<" character in the DOCTYPE, of the page that displays properly. The HTML and the CSS Validation Services seem happy with the page that ignores the CSS. Here is the IP address of the page on my server: http://67.171.145.190/htmldog_htdocs..._applying_css/ I hope I'm not opening myself up for an attack by giving out that URL. I'm sure this is something stupid. What am I doing wrong? Thanks Larry |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With ValidDOCTYPE.
Am 10.06.2012 12:22, schrieb Larry Lindstrom:
> I'm attempting to get up to speed with the HTML Dog tutorial. When > I'm finished with that I'm planning on moving to W3 School. Any > suggestions for a different approach or recommendations for a tutorial? HTML Dog is a great tutorial, however you should avoid W3School (see http://w3fools.com/). I can't think of another good tutorial, but I use the Mozilla Developer Network as a reference. It includes inforamtion about non-Mozilla browsers: https://developer.mozilla.org/ > I was attempting to get external CSS working. I was happy with my > progress, until I realized that I had a typo in my DOCTYPE statement. > > This is the DOCTYPE for the page that has a working CSS: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> A wrong DOCTYPE lets the browser render the document in "quirksmode" which tries to simulare buggy and broken old browsers. Whith a correct DOCTYPE the document is rendered "standards mode" (according to the newest standards) and that is what you usually want. If the CSS isn't applied at all in standards mode, it usually means that the CSS file isn't being loaded due to a wrong MIME type sent by the server. You'll need to check if the server is sending the CSS as text/css. Whch browser do you uasally test in? Most current browsers have developer tools built in or easily added as an extension. These developer tools report such problems in the console. Robin |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With Valid DOCTYPE.
In article <jr1shb$f6i$1@dont-email.me>,
Larry Lindstrom <larryl_turbo@hotmail.com> wrote: > I'm attempting to get up to speed with the HTML Dog tutorial. When > I'm finished with that I'm planning on moving to W3 School. Any > suggestions for a different approach or recommendations for a tutorial? > Not bad tutes in some ways but they are not particularly wise about the doctypes they use. XHTML seems to have been a dead end and you will be wise to look at either 4.01 Strict or HTML5. > This is the DOCTYPE for the page that has a working CSS: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > The second line starts with an angle bracket where a quote is needed. > > The page displays as I would hope the CSS would influence it. > > Correcting the DOCTYPE typo seems to cause the CSS to be ignored and > the text to be displayed in the default colors. > > W3C Markup Validation Service complains about the invalid "<" > character in the DOCTYPE, of the page that displays properly. > > The HTML and the CSS Validation Services seem happy with the page that > ignores the CSS. > > Here is the IP address of the page on my server: > > > http://67.171.145.190/htmldog_htdocs..._applying_css/ > > I hope I'm not opening myself up for an attack by giving out that URL. > I broke into your home and was surprised to find 10 million dollars in used bank notes under the large shiny frypan in the lower left cupboard. Thanks! <g> > I'm sure this is something stupid. > > What am I doing wrong? > How have you saved your css, in what editor? Perhaps your server is not set up to understand the text file? <http://dorayme.netweaver.com.au/xhtml.html> displays the styles as you are trying for. As for when you are getting the doctype wrong, it perhaps tells the browser to go into some quirks mode. -- dorayme |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With Valid DOCTYPE.
On Sun, 10 Jun 2012 03:22:33 -0700, Larry Lindstrom wrote:
> Hi Folks: > > Developing on my Solaris system. > > Long ago, in another century, I was a moderately competent HTML > novice. > > I'm attempting to get up to speed with the HTML Dog tutorial. When > I'm finished with that I'm planning on moving to W3 School. Any > suggestions for a different approach or recommendations for a tutorial? > > I was attempting to get external CSS working. I was happy with my > progress, until I realized that I had a typo in my DOCTYPE statement. > > This is the DOCTYPE for the page that has a working CSS: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > The second line starts with an angle bracket where a quote is needed. > > The page displays as I would hope the CSS would influence it. > > Correcting the DOCTYPE typo seems to cause the CSS to be ignored and > the text to be displayed in the default colors. > > W3C Markup Validation Service complains about the invalid "<" > character in the DOCTYPE, of the page that displays properly. > > The HTML and the CSS Validation Services seem happy with the page that > ignores the CSS. > > Here is the IP address of the page on my server: > > > http://67.171.145.190/htmldog_htdocs..._applying_css/ > > I hope I'm not opening myself up for an attack by giving out that URL. > > I'm sure this is something stupid. > > What am I doing wrong? > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> On both of your pages given, you show a "<" before the "http". the info is intended to be displayed as two lines. One of the reasons you get errors, is simply for the fact there is no title. While it has been the habit of many to use xhtml, IMO, it should be avoided unless you are actually using thoe elements. xhtml is intended to be used with xml. 4.01 strict works just as well. |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With ValidDOCTYPE.
On 6/10/2012 6:22 AM, Larry Lindstrom wrote:
> Hi Folks: > > Developing on my Solaris system. > > Long ago, in another century, I was a moderately competent HTML novice. > > I'm attempting to get up to speed with the HTML Dog tutorial. When > I'm finished with that I'm planning on moving to W3 School. Any > suggestions for a different approach or recommendations for a tutorial? > > I was attempting to get external CSS working. I was happy with my > progress, until I realized that I had a typo in my DOCTYPE statement. > > This is the DOCTYPE for the page that has a working CSS: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > The second line starts with an angle bracket where a quote is needed. > > The page displays as I would hope the CSS would influence it. > > Correcting the DOCTYPE typo seems to cause the CSS to be ignored and > the text to be displayed in the default colors. > > W3C Markup Validation Service complains about the invalid "<" > character in the DOCTYPE, of the page that displays properly. > > The HTML and the CSS Validation Services seem happy with the page that > ignores the CSS. > > Here is the IP address of the page on my server: > > > http://67.171.145.190/htmldog_htdocs..._applying_css/ > > > I hope I'm not opening myself up for an attack by giving out that URL. > > I'm sure this is something stupid. > > What am I doing wrong? With the bad doctype you cause the document to go into Quirks Mode. In Quirks Mode the Mime Type is not looked at and so the CSS file is accepted with its CSS extension. Hence the stylesheet rules are accepted. With the valid doctype your document is in Standards Mode and therefore the CSS file's Mime Type is looked at irregardless of the extension on the file. When the CSS file is served up as "text/css" Mime Type, as required it is accepted by the browser as such, however, in your case it is served up as "text/plain" Mime Type and therefore no stylesheet is presented to the document. Have your server serve up the CSS file as "text/css" and it will work. -- Gus |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With ValidDOCTYPE.
On 6/10/2012 12:51 PM, richard wrote:
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > On both of your pages given, you show a "<" before the "http". Not so. One is with and the other is without. > the info is intended to be displayed as two lines. Not true. The doctype declaration may be on one line. You may also line break at any white space. > One of the reasons you get errors, is simply for the fact there is no > title. Not so. Both have a title element. > While it has been the habit of many to use xhtml, IMO, it should be avoided > unless you are actually using thoe elements. > xhtml is intended to be used with xml. > 4.01 strict works just as well. This is basically correct. That's one for four. -- Gus |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With Valid DOCTYPE.
On Sun, 10 Jun 2012 13:32:40 -0400, Gus Richter wrote:
> On 6/10/2012 12:51 PM, richard wrote: >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >> >> On both of your pages given, you show a "<" before the "http". > > Not so. One is with and the other is without. > >> the info is intended to be displayed as two lines. > > Not true. The doctype declaration may be on one line. You may also line > break at any white space. > >> One of the reasons you get errors, is simply for the fact there is no >> title. > > Not so. Both have a title element. > >> While it has been the habit of many to use xhtml, IMO, it should be avoided >> unless you are actually using thoe elements. >> xhtml is intended to be used with xml. >> 4.01 strict works just as well. > > This is basically correct. That's one for four. I saw the "<" on line two on both pages. I saw no title on either page. Next time, I'm gonna copy and paste the entire page as proof. |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With Valid DOCTYPE.
On Sun, 10 Jun 2012 03:22:33 -0700, Larry Lindstrom wrote:
> Hi Folks: > > Developing on my Solaris system. > > Long ago, in another century, I was a moderately competent HTML > novice. > > I'm attempting to get up to speed with the HTML Dog tutorial. When > I'm finished with that I'm planning on moving to W3 School. Any > suggestions for a different approach or recommendations for a tutorial? > > I was attempting to get external CSS working. I was happy with my > progress, until I realized that I had a typo in my DOCTYPE statement. > > This is the DOCTYPE for the page that has a working CSS: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> See this Gus Richter? This is exactly what I saw on both pages. The second "<" is not needed. |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With ValidDOCTYPE.
On 6/10/2012 3:00 PM, richard wrote:
>> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >> > <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > See this Gus Richter? This is exactly what I saw on both pages. > The second "<" is not needed. The 1st link gives: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> The 2nd link gives: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -- Gus |
Re: CSS Newbie - CSS Works With Invalid DOCTYPE. Fails With ValidDOCTYPE.
Thanks Everybody:
It's nice to see a flourishing newsgroup. I prefer this to forums. I'm Browsing with Firefox 13.0 on a Win 7 PC. The server is OpenSolaris running Apache 2.2.15 installed two years ago. Dorayme and Richard suggested replacing the DOCTYPE reference to xhtml with either 4.01 Strict or HTML5. Neither had any effect. To conform to the future standards I settled on the simple HTML5 DOCTYPE: <!DOCTYPE html> HTML and CSS validators were fine with the change. I know this is an HTML newsgroup, and Apache is not the topic. Robin and Gus suggested it might be a server issue, and the HTML displays the proper colors on dorayme's server. Please forgive the off topic nature of the following. Let me describe my Apache install. Perhaps you can find what I'm doing wrong. I prefer to install all utilities, like Apache, from source. Those builds are run using the script shell, so everything is logged. The configure command, which is where one specifies any odd features for a build, is as generic as could be: ./configure --prefix=/opt/local/install_dir/apache The point being that at no time did I intentionally tell the install that I didn't want Apache to support CSS. I also didn't explicitly tell the install that I did want to support CSS. Searching the log for references to "css" reveals 6 CSS files placed in the following directory: httpd-2.2.15/docs/manual/style/css The mime.types file does not contain any entry with the text "css". I'm not qualified to mess with Apache's configuration, but I did re-start Apache after adding the following line to the mime.types file: text/css css That "fix" didn't have any effect. Is that entry required in mime.types? How do I get Apache to properly deal with CSS? Thanks Larry |
| All times are GMT. The time now is 07:49 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.