Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I've noticed that a lot of sites have something like this going on: <div class="has-margin-0 has-padding-4"> <div>...</div> <div>...</div> ... </div>...
#2: Post edited
- I've noticed that a lot of sites have something like this going on:
- ```html
<div class="has-margin-0 .has-padding-4">- <div>...</div>
- <div>...</div>
- ...
- </div>
- ```
- ```css
- .has-margin-0 {
- margin: 0;
- }
- .has-padding-4 {
- padding: 4px;
- }
- ```
- I'm a beginner who's self taught / internet searched most of their HTML and CSS knowledge. Currently I use human readable class names and style those instead of this weird (to me) method of moving the styling to classes. However, the "style by classes" method seems to be pretty popular for some reason, and I'd like to know why.
- What are the pros and cons of using that method?
- I've noticed that a lot of sites have something like this going on:
- ```html
- <div class="has-margin-0 has-padding-4">
- <div>...</div>
- <div>...</div>
- ...
- </div>
- ```
- ```css
- .has-margin-0 {
- margin: 0;
- }
- .has-padding-4 {
- padding: 4px;
- }
- ```
- I'm a beginner who's self taught / internet searched most of their HTML and CSS knowledge. Currently I use human readable class names and style those instead of this weird (to me) method of moving the styling to classes. However, the "style by classes" method seems to be pretty popular for some reason, and I'd like to know why.
- What are the pros and cons of using that method?
#1: Initial revision
Styling with classes vs styling with CSS
I've noticed that a lot of sites have something like this going on: ```html <div class="has-margin-0 .has-padding-4"> <div>...</div> <div>...</div> ... </div> ``` ```css .has-margin-0 { margin: 0; } .has-padding-4 { padding: 4px; } ``` I'm a beginner who's self taught / internet searched most of their HTML and CSS knowledge. Currently I use human readable class names and style those instead of this weird (to me) method of moving the styling to classes. However, the "style by classes" method seems to be pretty popular for some reason, and I'd like to know why. What are the pros and cons of using that method?