Hey guys, i’m fairly new to programming and codding and etc, and I’ve been doing the free code camp challenges for the past 2 days, and I’ve just entered CSS and I stumbled upon something that made me wonder, and I couldn’t find anything in other forums etc.
Why is that when you intend to style your text by using a block, we use it like this
As said. Because it is more readable and better syntax style. Some things are conventions, like how we use spaces, punctuation, or separate paragraphs (youcanreadthisbutitgetsreallyannoying)
Also, think about how the second example you have would look with more the just one style.
Aside from readability, it’s also easier to copy/paste sections when the tags are on separate lines. Ideally, you should use an editor that does syntax highlighting and formatting, so you can just hit the “reformat” key/button and not worry about getting it exactly right by hand.
Just to glom on, you’re encountering “block indentation,” a common styling convention wherein we use indentation to show which commands are grouped together, like this algorithm:
while (teeth are not clean)
Apply brush to a dirty area
For 10 times
Move brush left
Move brush right
end for
Spit
Rinse brush for 2 seconds
end while
I hope you can see how the layout of the code shows you what to do.
Thanks! Really helped me out with the concept, tou not that complicated, as a beginner I’m still getting some things figured out, so thanks, really appreaciate it
Its a very good question, wondering why we do things a certain way demonstrates critical thinking on your part. We should not just do things because that is how they are done, we should do things because we understand why they are done that way.