What Do Square Brackets in Class Names Mean

What do square brackets in class names mean?

That is most likely used by some sort of validator or validation library. The class here means that validate this field denoted by validate keyword and then:

required it is required field

custom validation type; allow only letters

length should be between 0 to 100 chars

Well, this information is used by the jQuery validation library you posted the link to :)

What is the reason to have (square) brackets in an element's class name?

This is nothing more other than visually separating classes with the intention of grouping them.

The example you gave both do the same exact thing.

The brackets are allowed in the class attribute and are technically valid so long as they have spaces between the bracket and the class itself.

Additional information about this technique can be found on csswizardy, and for posterity, here is an excerpt explaining how he uses it:

How it works

There is no hard and fast rule as to how and when to begin grouping
your classes, but the guidelines I’ve set for myself are:

There must be more than one ‘set’ of classes. One ‘set’ must contain
more than one class. This basically just ringfences any groups that
need it, for example:

<!-- Only one set. Nothing needs grouping. -->
<div class="foo foo--bar">

<!-- Two sets, but only one class in each. Nothing needs grouping. -->
<div class="foo bar">

<!-- Two sets, one of which contains more than one class. This set needs grouping. -->
<div class="[ foo foo--bar ] baz">

<!-- Two sets, both of which contain more than one class. These sets needs grouping. -->
<div class="[ foo foo--bar ] [ baz baz--foo ]">

How you group them
can be entirely your choice, the concept here just deals with the fact
that we’re grouping things at all.

What are the Square Brackets around the class name?

Grouping related classes in your markup where the square brackets could be used to group.
Please, read this Grouping related classes in your markup

What do square brackets, [], mean in function/class documentation?

The square brackets indicate that these arguments are optional. You can leave them out.

So, in this case you are only required to pass the csvfile argument to csv.DictReader. If you would pass a second parameter, it would be interpreted as the fieldnames arguments. The third would be restkey, etc.

If you only want to specify e.g. cvsfile and dialect, then you'll have to name the keyword argument explicitly, like so:

csv.DictReader(file('test.csv'), dialect='excel_tab')

For more on keyword arguments, see section 4.7.2 of the tutorial at python.org.

What does square bracket [] mean in the below code?

As @Spencer Ruport said, they're attributes. They're used within .NET for declarative programming.

You can find information on each of these attributes at MSDN. However, you should know that the name of the attribute can be shortened. In your case, for example, Category is the short form of the class name CategoryAttribute and XmlElement is the short form of the class name XmlElementAttribute. When declaring attributes, the Attribute portion of the class name can be left out.

I've used most of these attributes in conjunction with the PropertyGrid control (see here for an example), although in your case, they are used for a Web Part property pane. The purpose is still the same. The attributes are used by the control to know how to display the property to the user. By using a combination of the various attributes that the control understands, it is possible to declaratively dictate this behavior.

I hope that helps a little bit, but Spencer is correct, you'll learn a lot more reading about attributes via Google than I can explain here.

TypeScript - what do square brackets in property name mean?

That is not a typescript feature but a javascript one. It's called a computed property. Here are the docs for it.

Additionally, it does not create a property with the key eventName, but instead creates a property with a key that is the value of the variable eventName. Eg, if eventName = "foo", then {[eventName]: "bar"} is the same as {foo: "bar"}.



Related Topics



Leave a reply



Submit