Starlit Daily

📚 › CSS: style and layout

2. Selectors: element, class, id

ستتم ترجمة هذا المقال تلقائيًا. يُعرض بالإنجليزية حاليًا.

An element selector (p) styles all paragraphs. A class selector starts with a dot (.note) and styles every element with that class. An id selector starts with # (#main) and matches one element on the page.

Use classes for styles you reuse. Use ids sparingly.

عرض المثال

.note {
  background: #fef9c3;
}
#main {
  max-width: 600px;
}

✍️ دورك الآن

Give every element with class warning the colour red.

← العودة إلى الدورة