473,320 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Overriding generated content inserted via the :before pseudo element

http://homepage.ntlworld.com/spartanicus/temp3.htm

p:before{content:"foo"}
p:before{content:none}

<p>bar</p>

renders as "foobar". I thought that according to the "latter specified
wins if two rules have the same weight, origin and specificity" cascade
rule it would render as "bar", but apparently I'm missing something. Can
someone point me to the spec section that explains this behaviour?

--
Spartanicus
Sep 27 '05 #1
5 5187
In article
<4a********************************@news.spartanic us.utvinternet.ie>,
Spartanicus <in*****@invalid.invalid> wrote:
http://homepage.ntlworld.com/spartanicus/temp3.htm

p:before{content:"foo"}
p:before{content:none}

<p>bar</p>

renders as "foobar". I thought that according to the "latter specified
wins if two rules have the same weight, origin and specificity" cascade
rule it would render as "bar", but apparently I'm missing something. Can
someone point me to the spec section that explains this behaviour?


content:none isn't valid CSS, so it's up to the user-agent to decide
what to do. Refusing to render invalid code isn't considered acceptable
by the public, so it is to be expected that a user-agent will simply
ignore the rule.

If you change to this

p:before{content:"foo"}
p:before{content:""}

<p>bar</p>

the user-agenst should render "bar". iCab, Safari, Mozilla and Opera all
do.

--
Sander Tekelenburg, <http://www.euronet.nl/%7Etekelenb/>
Sep 28 '05 #2
Sander Tekelenburg <us**@domain.invalid> wrote:
content:none isn't valid CSS


http://www.w3.org/TR/CSS21/generate.html#content

--
Spartanicus
Sep 28 '05 #3
Sander Tekelenburg <us**@domain.invalid> wrote:
content:none isn't valid CSS


Just discovered that it's in CSS 2.1, but not in CSS 2.0. That's the
first time that I've been caught out in using CSS 2.1 and finding that
modern browsers still implement the CSS 2.0 values.

--
Spartanicus
Sep 28 '05 #4
In article
<6f********************************@news.spartanic us.utvinternet.ie>,
Spartanicus <in*****@invalid.invalid> wrote:
Sander Tekelenburg <us**@domain.invalid> wrote:
content:none isn't valid CSS


http://www.w3.org/TR/CSS21/generate.html#content


Oh my. Turns out I was looking at a local copy of an earlier draft
(2004-02-25) which didn't yet contain this...

Btw, the section on changes between CSS 2.0 and 2.1 doesn't list this
change. Seems like this change is so recent it didn't even make it into
the change log. Not too surprising then that browsers don't support it
yet (besides, CSS 2.1 is still only a draft anyway). Or perhaps the
change log simply contains a typo? Something about that sentence at
<http://www.w3.org/TR/CSS21/changes.html#q4> confuses me.

--
Sander Tekelenburg, <http://www.euronet.nl/%7Etekelenb/>
Sep 28 '05 #5
Sander Tekelenburg <us**@domain.invalid> wrote:
Btw, the section on changes between CSS 2.0 and 2.1 doesn't list this
change. Seems like this change is so recent it didn't even make it into
the change log.
Good catch.
Not too surprising then that browsers don't support it
yet (besides, CSS 2.1 is still only a draft anyway).
I tend to think of CSS 2.1 primarily as clarifying issues with 2.0 and
removing stuff that wasn't implemented, I forgot that there were minor
changes, and a few additions other than inline-block.
Or perhaps the change log simply contains a typo?
I'll mention it on the w3c style mailing list.
Something about that sentence at
<http://www.w3.org/TR/CSS21/changes.html#q4> confuses me.


Same here :)

--
Spartanicus
Sep 28 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marlin | last post by:
I am inquiring for a customer of mine who is using XMetal 3.0 as an XML editor. I am trying to add default content to an element so that this content is inserted when the element is inserted. ...
3
by: Headless | last post by:
Should linking generated content work? Example: span:before{content:"foobar"} <a href="foobar.htm"><span></span></a> I stumbled across this bit in the CSS2 spec: >Generated content does...
0
by: Jimmy Cerra | last post by:
I recently came up with a cool little stylesheet for definition lists. There is a small demostration for the impatient . I hope this helps someone. Here's how I did it. Definition lists are...
21
by: TonyV | last post by:
Hi all, I'm trying to use some javascript code in Internet Explorer 6.0 that's being generated by a Perl file. I have a line in my header that looks something like this: <script...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.