9 replies [Last post]
RichardOnRails
Offline
Regular
Last seen: 14 years 11 weeks ago
Timezone: GMT-4
Joined: 2007-09-03
Posts: 18
Points: 0

Hi All,

Earlier today, I wanted to post this question but had an overriding issue: I had failed to include [[rel="stylesheet" ]] in my Link statement. Now that I've gotten help on that issue, here's my real problem:

I have commented rules in embedded CSS. It works fine but fails validation.

Restructured to external CSS, it still works fine, but everything validates.

So what am I messing up?

Thanks in advance,
Richard

http://home.comcast.net/~CaptQueeg/CommentsInEmbeddedStylesheet.html


Comments in Embedded Stylesheet


H1 {color:red} /* H1 rule */
H2 {color:blue} /* H2 rule */

H1 Heading

H2 Heading

http://home.comcast.net/~CaptQueeg/CommentsInExternalStylesheet.html


Comments in External Stylesheet

H1 Heading

H2 Heading

http://home.comcast.net/~CaptQueeg/CommentsInExternalStylesheet.css
H1 {color:red} /* H1 rule */
H2 {color:blue} /* H2 rule */

Ruby on Rails enthusiast
Learning CSS to use ROR more effectively
WinXP/SP2
Firefox, SeaMonkey, Aptana

Vade
Vade's picture
Offline
Enthusiast
Ireland
Last seen: 11 years 9 weeks ago
Ireland
Joined: 2007-08-13
Posts: 315
Points: 276

Here's your problem,

Here's your problem,

You need to have the type value in quotation marks so its..

Its something thats very easy to overlook but can cause you a world of problems.

RichardOnRails
Offline
Regular
Last seen: 14 years 11 weeks ago
Timezone: GMT-4
Joined: 2007-09-03
Posts: 18
Points: 0

[[type="text/css"]] was the answer

Thanks. I keep a template so that all the basic code I need to start a document with embedded or external CSS is ready to go. I had two or three mistakes in it. Hopefully, this is the last of them.

BTW, one of my earlier posts now has the phrase "[Solved]" prepended. Presumably, that was done by the moderators. Should we do that ourselves to assist them?

Again, thanks for that solution. It's duly record in my template Smile

Ruby on Rails enthusiast
Learning CSS to use ROR more effectively
WinXP/SP2
Firefox, SeaMonkey, Aptana

Phreestyle
Phreestyle's picture
Offline
Enthusiast
Australia
Last seen: 6 years 2 weeks ago
Australia
Timezone: GMT+8
Joined: 2007-05-12
Posts: 235
Points: 6

I think the validation

Hi Richard
I think the validation problem with your embedded style lies in the fact that you are checking your markup with the HTML validator. CSS comment tags /*example comment here*/ are not valid HTML as far as the parser is concerned.

I modified your code and got the friendly green screen.



Comments in Embedded Stylesheet

H1 {color:red}
H2 {color:blue}


H1 Heading

H2 Heading

I always try to mark my topics as 'solved'. I think it helps out other people who use the forum. (Well it helps me when i'm searching for a solution to a problem).

Cheers,

Life's a journey. Enjoy the trip.

SuperRoach
SuperRoach's picture
Offline
Enthusiast
Ballarat
Last seen: 10 years 21 weeks ago
Ballarat
Timezone: GMT+10
Joined: 2007-02-26
Posts: 291
Points: 6

H1 {color:red} H2

 H1 {color:red}   
H2 {color:blue} 

Looking at your code there, you should never be able to do that - even with it in the webpage. The only way to add comments is the usual /* comment here */ technique. The

Tyssen
Tyssen's picture
Offline
Moderator
Brisbane
Last seen: 7 years 15 weeks ago
Brisbane
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8201
Points: 1386

Phreestyle wrote:I think the

Phreestyle wrote:
I think the validation problem with your embedded style lies in the fact that you are checking your markup with the HTML validator. CSS comment tags /*example comment here*/ are not valid HTML as far as the parser is concerned.

CSS comments using /* */ are fine. The reason it doesn't validate in your example is because you left " " off type="text/css".

Like Superoach says, I wouldn't recommend using HTML comments in your CSS because if you ever move the styles to an external sheet, it'll start screwing things up.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 3 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

This seems a rather confused

This seems a rather confused thread Smile

Comments are allowed in embedded style tags; what wouldn't be allowed is to nest comments of any variety, i.e if you inserted html comments before and after the rulesets to prevent older browsers parsing the the rules as text then you couldn't have a further set of html comments nested that had character data in as that would throw an error.

It's difficult to know what exactly was going on though as the test case doesn't demonstrate the problem if asking about a problem then the example needs to show that problem! and it is better that it doesn't carry over errors (missing quotes) mentioned in previous threads that might just distract people from the issue being asked about.

Appropos of marking threads 'resolved' if you can it's helpful.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

RichardOnRails
Offline
Regular
Last seen: 14 years 11 weeks ago
Timezone: GMT-4
Joined: 2007-09-03
Posts: 18
Points: 0

[Solved] The first reply on this thread solved the my problem

Hi All,

The first reply I got on this thread solved my problem: [[type="text/css"]] was the answer.

So I view the matter as closed. No other discussion is warrented, IMHO. But I did learn that prefixing "[Solved]" to a reply is desirable, which I've done here. That's good to know.

Best wishes,
Richard

Ruby on Rails enthusiast
Learning CSS to use ROR more effectively
WinXP/SP2
Firefox, SeaMonkey, Aptana

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 3 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Richard that was pointed out

Richard that was pointed out in the threadwhich is why I mentioned earlier that you had carried over an error in your test case, this thread wasn't necessary really Smile look at Barry's comment about missing 'quotes'

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

RichardOnRails
Offline
Regular
Last seen: 14 years 11 weeks ago
Timezone: GMT-4
Joined: 2007-09-03
Posts: 18
Points: 0

[Solved] Thanks to all for responding

Hi Hugo,

> that was pointed out ...

I'm just focused on the bottom line: I got the thing working the way I expected to, so I'm a happy camper on the way to my next CSS obstacle.

Best wishes,
Richard

Ruby on Rails enthusiast
Learning CSS to use ROR more effectively
WinXP/SP2
Firefox, SeaMonkey, Aptana