Omnimaga

General Discussion => Technology and Development => Web Programming and Design => Topic started by: flyingfisch on June 13, 2012, 06:07:44 pm

Title: CSS question
Post by: flyingfisch on June 13, 2012, 06:07:44 pm
Dumb question I know, but anyway. How do I change the properties for a tag inside a class?

example:

Code: [Select]
<tag class="class">
  <atag></atag>
<tag>

To edit stuff for atag, is it

Code: [Select]
.class atag {
stuff
}

Or is it

Code: [Select]
atag .class {
stuff
}

Thanks
Title: Re: CSS question
Post by: Eeems on June 13, 2012, 07:22:14 pm
Code: [Select]
atag.class{
  /* stuff */
}
or
Code: [Select]
.class{
   /* stuff */
}
Although this will affect anything with this class. You can also use
Code: [Select]
atag{
   /* stuff */
}
For all references of atag
Title: Re: CSS question
Post by: Deep Toaster on June 13, 2012, 07:26:08 pm
Code: [Select]
atag.class{
  /* stuff */
}
Eeems, he wants to know how to target atag as a descendant of .class, not the element itself.

What you're looking for is
Code: [Select]
.class atag
{
    /* stuff */
}
(your first guess, flyingfisch).
Title: Re: CSS question
Post by: Eeems on June 13, 2012, 07:56:46 pm
Oh right lol, I just skimmed the question.
Another more specific way to do this would be
Code: [Select]
tag.class atag{
   /* stuff */
}
Title: Re: CSS question
Post by: flyingfisch on June 13, 2012, 07:58:43 pm
Thanks for the replies guys :)
Title: Re: CSS question
Post by: DJ Omnimaga on June 13, 2012, 08:14:55 pm
To prevent any confusion, could you explain what is <atag> though? Can one just use any nonexistent tag in his HTML code to assign CSS properties to it?
Title: Re: CSS question
Post by: Juju on June 13, 2012, 10:55:18 pm
Well, you can actually use nonexistant tags and your browser won't even complain. It won't pass the W3C Validator though. And I never tried it, but I think the CSS parser won't even care if your tag exists or not.
Title: Re: CSS question
Post by: Eeems on June 14, 2012, 02:40:13 am
Some might throw warnings. I know I've used non-existent tags before. Not a good idea to do though.
Title: Re: CSS question
Post by: flyingfisch on June 14, 2012, 10:07:14 am
To prevent any confusion, could you explain what is <atag> though? Can one just use any nonexistent tag in his HTML code to assign CSS properties to it?

The reason I used <atag> was just to create some arbitrary code.

It could be any tag like <span>, <div>, etc. ;)