Jump to content

Observation on the Class selector - from CSS Newbie student


amakeler

Recommended Posts

Hi all, Subject: Observation on the Class selector - from CSS Newbie studentNow I am learning CSS from W3S, I just thought that I would point out that the syntax of the Class selector is the reverse of what is intuitive to an old-time programmer, imo.In C++ and other languages, you first define the class with the "Class" directive/key-word/reserved-word (or which ever word you use to indicate a "class"), and then you use it without stating the word "Class", so you get a short-hand notation in usage.However, in CSS I note that when you define the class you do not specify the word 'class", but when you use the class you do specify the word 'class", which causes a very long-winded usage notation, and which has to be repeated every time. Below is an example from the tutorial:<head>p.sansserif {font-family: sans-serif}</head><body><p class="sansserif">This is a paragraph</p></body>I would have designed it like this: <head>p Class sans {font-family: sans-serif}</head><body><p.sans>This is a paragraph</p></body>- avi

Link to comment
Share on other sites

that is also the biggest drawback of programming language but we have to accept but if having only one language, does it sense pleased ???just imaging that you have to pass by several doors with different height, you must stoop, straight or even crawl ... I am talking about protocol :)

Link to comment
Share on other sites

that is also the biggest drawback of programming language but we have to accept but if having only one language, does it sense pleased ???just imaging that you have to pass by several doors with different height, you must stoop, straight or even crawl ... I am talking about protocol :)
I am starting to get more serious about CSS, so I read a CSS specification: http://www.w3.org/TR/CSS21/selector.html#q2 Belive it or not, but see 5.8.3 Class selectors, where it seems to say that you CAN specify class usage by using a dot notation, as I suggested with:<body><p.sans>This is a paragraph</p></body>But I did not see that you can define a class using teh word "class".- avi
Link to comment
Share on other sites

I am starting to get more serious about CSS, so I read a CSS specification: http://www.w3.org/TR/CSS21/selector.html#q2 Belive it or not, but see 5.8.3 Class selectors, where it seems to say that you CAN specify class usage by using a dot notation, as I suggested with:<body><p.sans>This is a paragraph</p></body>But I did not see that you can define a class using teh word "class".- avi
I believe I read that specification differently than you because I don't think it's possible to do what you are saying:
<html><head><style>p.test { background-color: red; }</style></head><body><p.test>This paragraph will <b>not</b> have a red background.</p><p class="test">This paragraph will have a red background.</p></body></html>

Link to comment
Share on other sites

that is also the biggest drawback of programming language but we have to accept but if having only one language, does it sense pleased ???just imaging that you have to pass by several doors with different height, you must stoop, straight or even crawl ... I am talking about protocol :)
I am starting to get more serious about CSS, so I read a CSS specification: http://www.w3.org/TR/CSS21/selector.html#q2 Belive it or not, but see 5.8.3 Class selectors, where it seems to say that you CAN specify class usage by using a dot notation, as I suggested with:<body><p.sans>This is a paragraph</p></body>(But I did not see that you can also define a class using the word "class"...)- avi
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...