Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the same value to multiple properties (CSS)

Tags:

css

This seems like such a stupid question but I can't find the answer anywhere.

Is there a way to set multiple CSS properties to one value

border-left, border-right: 1px solid #E2E2E2; 

the way that you can do with selectors?

.wrapper, .maindiv { ... } 
like image 493
Artur Sapek Avatar asked Aug 30 '11 07:08

Artur Sapek


People also ask

Can you edit multiple properties in one CSS?

Good News! You can layer multiple transform values, and yes, you can do it in one CSS property as well.

How do you set multiple property declarations in a CSS rule?

The declaration block contains one or more declarations separated by semicolons. Each declaration includes a CSS property name and a value, separated by a colon. Multiple CSS declarations are separated with semicolons, and declaration blocks are surrounded by curly braces.

What is Multiple property CSS?

Declaring multiple properties in a single rule allows you to apply many style instructions—such as size, color, and alignment—to an element all at once. We'll also explore creating a variety of CSS rules that allow us to apply different styles to different pieces of content in a single HTML document.

What type of CSS properties allow developers to set several values for a property in a single line?

Shorthand properties are CSS properties that let you set the values of multiple other CSS properties simultaneously. Using a shorthand property, you can write more concise (and often more readable) style sheets, saving time and energy.


1 Answers

Nope. But for your example, you can do this:

border: solid #E2E2E2; border-width: 0 1px; 

The attributes where there can be separate values for top, right, bottom, and left (eg, border-*, margin, padding) can usually be combined in a single attribute.

like image 61
gilly3 Avatar answered Oct 12 '22 13:10

gilly3