Using new properties - identifying the right ones in the first shot without using search engines
I was recently doing a CSS course from www.codeschool.com. It was a beginner's course.
One of their challenges in Level 1 was -
- Select the slogan only by its ID attribute, then center the text and make it italic. If you don't remember the CSS properties, refer to Mozilla's CSS Reference. *
I started writing my solution and my initial solution looked like -
#slogan {
text: center;
font-style: italic;
}
On submit, I got a message which kinda read - "Did not align the text to the center". I soon realized, that the CSS property that I was using in the above code wasn't correct, but I also wasn't sure about the right property to use at that very moment.
I thought let me just give it a try and I made use of something with the keyword 'align'. So I changed text
to text-align
and hit the submit, it worked like a charm :). Below is the right way to do it and you'll actually see the color difference when you try comparing the old code above to the new one below.
#slogan {
text-align: center;
font-style: italic;
}
My Learning -
I realized that as I was typing and changing the text
to text-align
, in their editor(and this I also verified with Sublime Text 2 later on), the color of the property also changed and it exactly matched the color of the other property font-italic
which made me realize without using google, that I had actually used the right property name. Reflecting back on this made me realize that this kinda applies to so many languages and I was left smiling away as to why I didn't think of this earlier.. :) .
I'm not sure some(may be many) of you might feel what's the big deal in this as you would have probably observed it earlier, it was just something that I felt worth sharing because in today's era of getting things done faster where people would try to even avoid an extra click if they can find a way to save their precious time through shortcuts, this would definitely also be a time saver for those who might have overlooked this thing(happened to me until today :)) that happens to do things on the same lines of saving time.
Also, this kinda gives me a feeling of having a deeper respect for the syntax highlighting feature that many code editors provide . Thanks to them(and their developers), as a coder I can now better realize how much more time I'm actually saving on a day to day basis using the right syntax at the right places.
I'd be glad to know if you find this useful and or may be even if you simply related to/had this experience in anyway.