eozzy
eozzy

Reputation: 68710

CSS Brace Styles

I'm unable to figure how the standard (or just popular) brace style names apply to CSS. Here're all the brace styles:

/* one - pico? */
selector { property: value; 
           property: value; }

/* two - pico extra */
selector { 
    property: value; /* Start Properties on Newline */
    property: value; }

/* three - horstmann? */
selector 
{ property: value;
  property: value;
}

/* four - GNU? */
selector 
{ 
    property: value; /* Start Properties on Newline */
    property: value;
}​

/* five - GNU Saver */
selector { property: value;
           property: value;
}

/* six - CSS Default */
selector { 
    property: value; /* Start Properties on Newline */
    property: value;
}

/* seven - Braces Aligned */
selector { property: value;
           property: value;
         }

/* eight - Banner? */
selector {
    property: value; /* Start Properties on Newline */
    property: value;
    }

Can someone please name each brace style for me?

Many thanks!

Upvotes: 5

Views: 3900

Answers (4)

andreaslangsays
andreaslangsays

Reputation: 329

four should be Allman Style

it's my favorite

Upvotes: 2

TheDeadMedic
TheDeadMedic

Reputation: 9997

I would say three is Horstmann.

Pico as it is, but the opening brace starts on a newline.

Banner would be:

selector {
    property: value;
    property: value;
    }

The rest of your guesses seem correct.

I took most of these from Indent style on Wikipedia :)

Upvotes: 7

hellozimi
hellozimi

Reputation: 1878

I sometimes write css with the starting- and ending brace on the same line.
Often used like:
.foo {width:100%;height:550px;}

How would this be named?

/* Nine - Almost-optimized(?) */
selector { property: value; property: value; }

Upvotes: 1

Ivy Evans
Ivy Evans

Reputation: 772

I think you named the most popular indent styles yourself. I personally, prefer:

.class {
  property: value;
}

Upvotes: 2

Related Questions