Tailwind في مقابل CSS التقليدي
قارن بين التنسيق القائم على الأدوات وكتابة CSS العادي وBEM، وتعلّم متى يتفوّق كل نهج.
Tailwind في مقابل CSS التقليدي درس مجاني في Tailwind CSS Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Tailwind CSS Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Tailwind CSS Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
The Old Way: Semantic CSS
The old way is semantic CSS: descriptive class names like .navbar or .card in a separate file, meant to describe purpose. Methods like BEM grew from this.
/* Traditional CSS */
.hero-title {
font-size: 3rem;
font-weight: 800;
color: #111827;
letter-spacing: -0.025em;
margin-bottom: 1.5rem;
}
<h1 class="hero-title">Build Something Great</h1>What Is BEM?
BEM means Block, Element, Modifier: a Block like .card, an Element like .card__title, and a Modifier like .card--featured. Clear, but it takes discipline.
<!-- BEM naming convention -->
<div class="card card--featured">
<img class="card__image" src="thumb.jpg" alt="" />
<h2 class="card__title">Featured Post</h2>
<p class="card__description">A short summary...</p>
<a class="card__link card__link--primary" href="#">Read More</a>
</div>The Same Card in Tailwind
Here is that same card in Tailwind. No CSS file at all — every choice shows in the HTML: rounded-xl shadow-md for shape, text-xl font-bold for the title.
<!-- Tailwind equivalent -->
<div class="rounded-xl shadow-md overflow-hidden bg-white border border-indigo-200">
<img class="w-full h-48 object-cover" src="thumb.jpg" alt="" />
<div class="p-6">
<h2 class="text-xl font-bold text-gray-900 mb-2">Featured Post</h2>
<p class="text-gray-500 text-sm mb-4">A short summary...</p>
<a class="text-indigo-600 font-semibold hover:underline" href="#">Read More</a>
</div>
</div>The Specificity Problem in Traditional CSS
Traditional CSS has a specificity headache: rules fight over which wins, leading to !important everywhere and brittle code. Tailwind utilities stay predictable.
/* Specificity conflict example */
.sidebar .card .card__title { color: red; } /* specificity: 0,3,0 */
.featured-section .card__title { color: blue; } /* specificity: 0,2,0 */
/* Which color wins? Depends on file order AND specificity */
/* This becomes unmanageable at scale */CSS File Growth Over Time
Plain CSS files grow forever because nobody dares delete old rules. Tailwind strips unused utilities at build time, so your CSS never piles up dead weight.
Switching Between Files
With classic CSS you keep switching between HTML and CSS for every tweak. Tailwind keeps you in the HTML, which speeds up your workflow a lot.
<!-- With Tailwind: no CSS file to open -->
<button class="py-2 px-4 bg-green-500 text-white rounded hover:bg-green-600">
Submit
</button>
<!-- With traditional CSS: go find/create .submit-button in your CSS file -->
<button class="submit-button">Submit</button>When Traditional CSS Still Wins
Sometimes traditional CSS still wins: styling third-party HTML you cannot edit, complex keyframe animations, or a public stylesheet for other developers.
/* Complex animation: better in CSS than utility classes */
@keyframes wave {
0%, 100% { transform: rotate(-10deg); }
50% { transform: rotate(10deg); }
}
.wave-animation {
animation: wave 1s ease-in-out infinite;
}Consistency: Scales vs Freeform Values
Tailwind quietly enforces consistency. Instead of hand-typed 13px or 17px padding, you pick from a 4px scale, so designs stay harmonious by default.
<!-- Tailwind spacing: always consistent multiples -->
<div class="p-4"> <!-- 16px -->
<div class="p-6"> <!-- 24px -->
<div class="p-8"> <!-- 32px -->
<!-- vs Traditional CSS: any value is valid -->
div { padding: 13px; } /* Why 13? Nobody knows. */Performance Comparison
Will all those classes hurt performance? No — repeated classes compress brilliantly, and Tailwind CSS is usually far smaller than an unoptimized stylesheet.
Team Onboarding: Tailwind vs CSS
Onboarding is easier too. Anyone who knows the Tailwind docs can read and edit any component, since class names mean the same thing in every project.
Choosing the Right Approach
So which to choose? Tailwind for app UI and design systems you control; traditional CSS for theming or CMS HTML. Many projects happily use both.
Quick Check
Quick check! Compare Tailwind and CSS in your head. ⚖️
Lesson Recap
Nice work! Traditional CSS names things in files while Tailwind composes in HTML, BEM does not fix file growth, and the scale enforces consistency. Next: typography.
تعلم HTML مع معلم ذكاء اصطناعي — مجانًا
اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.
- الدورات
- 30
- الدروس
- 120
الأسئلة الشائعة
هل درس «Tailwind في مقابل CSS التقليدي» مجاني؟
نعم — نص درس «Tailwind في مقابل CSS التقليدي» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Tailwind CSS Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Tailwind CSS Academy 4 دروس في المجموع.
ماذا ستتعلم في «Tailwind في مقابل CSS التقليدي»؟
قارن بين التنسيق القائم على الأدوات وكتابة CSS العادي وBEM، وتعلّم متى يتفوّق كل نهج. تتمرن على Tailwind CSS Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Tailwind CSS Academy؟
لا تُشترط خبرة سابقة. Tailwind CSS Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «Tailwind في مقابل CSS التقليدي»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Tailwind CSS Academy هذا؟
نعم. كل درس في Tailwind CSS Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- شرح CSS القائم على الأدوات
- تثبيت Tailwind وإعداده
- أولى صفحاتك باستخدام Tailwind
- Tailwind في مقابل CSS التقليدي