
0
Defining CSS Attribute Selectors
Hi Guys,
I'm in the process of setting up a email template for a client and after doing my research i've come across various different ways of defining CSS attribute selectors. Just wondering what peoples thoughts are on the subject and if one is more best practice than the others:
Examples:
*[ class="name" ] - (speech marks)
*[ class=name ] - (no speech marks)
*[ class=~"name" ] - (use of tilda)
The speech marks aren't required, doesn't cause any issues as fas as I'm aware to remove them.
The tilda means 'exactly contains'
So if you had
class="foo bar"
[ class="foo" ]{}
would not match it[ class="foo bar" ]{}
would match it[ class~="name" ]{}
would match itYou can also use
$=
ends with^=
starts with and*=
loosely contains (this will matchclass-"foo"
andclass="fooooo"
Thanks for clarifying.. definitely food for thought,