sayth
sayth

Reputation: 7028

CSS link attributes in classes .net

How can you specify link attributes inside a class in main.css.

The standard link attribute is fine when put in a non defined area of the CSS file.

a:link { color:white }

However if I want to create a class so that I am only defining how the attributes apply to a menu it errors as a syntax error. For example.

menuLinks {
           a:link { color:white }
}

Will show as an error, so how can I define link attributes within a class. I am using visual web developer 2010

Upvotes: 1

Views: 124

Answers (2)

freefaller
freefaller

Reputation: 19953

You cannot "nest" brace blocks.

Assuming menuLinks is the id of the object, use this...

#menuLinks a:link { color:white; }

If menuLinks is the class of the object, use this...

.menuLinks a:link { color:white; }

UPDATE based on comments...

Instead of having the individual blocks like this...

#Menu a:link { color:white; }
#Menu a:link { text-decoration:none; }

You can combine them into a single block...

#Menu a:link { color:white; text-decoration:none; }

Which can also be written like this which can be easier to read, depending on how many items you have...

#Menu a:link {
  color:white;
  text-decoration:none;
}

Upvotes: 2

Quentin
Quentin

Reputation: 943097

Use a descendent selector

menuLinks a:link {}

Note that:

  • menuLinks will match <menuLinks> which is not valid HTML
  • CSS doesn't have classes (and is not an object oriented programming language). It has rules, which are contained in rule-sets, which are prefixed with a selector. (CSS does have a class selector which selects HTML (or other markup language) classes)
  • CSS doesn't have attributes, it has values, properties, rules, rule-sets, and a few other things.

Upvotes: 1

Related Questions