Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Cant use attribute selectors on html tag
Old 10-11-2011, 09:56 PM Cant use attribute selectors on html tag
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
Not so long ago I discovered CSS attribute selectors and it was a revelation to me. No more need to add extra classes or IDs if we can use the attribute hooks to pinpoint a piece of html to style.

for example

Code:
a[title="hide me"]{display:none}
will remove anything from the page with the title attribute "hide me".

Terrific stuff.

However, today I have been trying to use the <html xml:lang> attribute
to target a particular language version to style.

What I want to do is something like this

Code:
html[xml:lang="en"] a[title="hide me"]{display:none}
to hide a link from the English language version only.

But it doesn't seem to work.
Any clues?
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is online now
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-12-2011, 03:25 AM Re: Cant use attribute selectors on html tag
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
That's because xml:lang is not actually an attribute.
It is a namespace identifier for the "human readable" language to be used by the XML processor.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-12-2011, 04:36 AM Re: Cant use attribute selectors on html tag
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
I see. That's clear now, thanks.
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is online now
Reply With Quote
View Public Profile
 
Old 10-14-2011, 05:26 AM Re: Cant use attribute selectors on html tag
Average Talker

Posts: 17
Trades: 0
Quote:
Code:
a[title="hide me"]{display:none}
will remove anything from the page with the title attribute "hide me".
Doesn't that have a poor browser (IE) support?
FrankknarF is offline
Reply With Quote
View Public Profile
 
Old 10-14-2011, 10:39 PM Re: Cant use attribute selectors on html tag
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
Quote:
Originally Posted by FrankknarF View Post
Doesn't that have a poor browser (IE) support?
Note: IE7 and IE8 support attribute selectors only if a !DOCTYPE is specified. Attribute selection is NOT supported in IE6 and lower.

Source:
http://www.w3schools.com/css/css_att..._selectors.asp


You should always use a DOCTYPE anyway
and I've dropped support for IE6 ,
so no problems with using this from my point of view at least.
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE

Last edited by TWD; 10-14-2011 at 10:43 PM..
TWD is online now
Reply With Quote
View Public Profile
 
Old 10-14-2011, 10:57 PM Re: Cant use attribute selectors on html tag
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
As a side note, the easiest and, conveniently, the most current DOCTYPE is simply <!DOCTYPE html>. That's the HTML5 DOCTYPE. My standard site 'shell' goes like this (without meta keywords, descriptions, styles, etc):

HTML Code:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>My Site</title>
</head>
<body>

</body>
</html>
Another thing to note is that margin:0px auto; won't work without a DOCTYPE. So if something is glitching up, check your DOCTYPE.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 10-15-2011, 11:17 AM Re: Cant use attribute selectors on html tag
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
Yes. Really, the only reason for having a !DOCTYPE is so that
IE doesnt get thrown into "quirks mode".

Any valid !DOCTYPE will do.

So you may as well start using <!DOCTYPE html> right now.

Even sorry little IE6 will recognize it.
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is online now
Reply With Quote
View Public Profile
 
Old 10-15-2011, 11:39 AM Re: Cant use attribute selectors on html tag
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Even sorry little IE6 will recognize it.
Ah but it still won't stop it breaking things.

But joking aside IE6, IE7 and some earlier builds of IE will be in "quirks mode" because the HTML5 DTD is not coded into them, nor will it ever be, so the <header>,<footer> etc elements will simply be ignored.
But I would have thought by now people who are still using IE6 or IE7 will be getting used to some websites looking "odd".
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-15-2011, 06:54 PM Re: Cant use attribute selectors on html tag
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Ah but it still won't stop it breaking things.

But joking aside IE6, IE7 and some earlier builds of IE will be in "quirks mode" because the HTML5 DTD is not coded into them, nor will it ever be, so the <header>,<footer> etc elements will simply be ignored.
But I would have thought by now people who are still using IE6 or IE7 will be getting used to some websites looking "odd".
According to Stack Overflow, the DOCTYPE doesn't put IE6 in quirks mode
http://stackoverflow.com/questions/5...-html-as-html5

I would have thought IE6 ignores <header> <footer> etc without actually throwing out quirks mode.

Is that what you mean?
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is online now
Reply With Quote
View Public Profile
 
Old 10-15-2011, 07:16 PM Re: Cant use attribute selectors on html tag
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yep but they do say SHOULD be not will be

Quote:
I would have thought IE6 ignores <header> <footer> etc without actually throwing out quirks mode.
unknown or invented tags do not affect rendering in any way shap or form

You could add
HTML Code:
<wibble> this will just be text </wibble>
to the source code of any HTML document and ALL browsers will simply strip out the "tags" and leave the text visible and styled as the parent container or the style cascade dictates.
If they don't exist in the DOM as defined by the Doctype they simply have no defined benaviour.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Cant use attribute selectors on html tag
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.22718 seconds with 12 queries