Skip to main content

S3 V6 - Class and ID (ENGLISH/URDU) Tutorial | Phase 1


S3 V6 - Class and ID (URDU) Tutorial | Phase 1


S3 V6 - Class and ID (ENGLISH) Tutorial | Phase 1




Understand and learn concept of Class and ID in Urdu Tutorial.

files - - https://goo.gl/QTY6E8


This article elaborates the difference between CSS Class and ID.

To understand the difference, consider the example of a group children in a school; they are categorized into classes as Grade 1 - Red, Grade 1 - Blue. The problem of this categorization is that if they all are made to stand together as a crowd then an outsider cannot identify the grade colours of the students. An outsider can only identify when they see them sitting in their respective classes. In this condition, if the outsider is asked " Hey outsider, please identify which students belong to grade 1 - red!" They would of course reply "No. How can I identify the students when they have no proper identifier?"

The management now decides to change uniforms of each class according to their colours, so that the Grade 1 - Blue students will wear blue uniform, and Grade 1 - Red students will now wear red uniform. Now, an outsider can easily identify the two classes with their uniforms. If the outsider is now asked the same question "Hey Outsider, please identify which students of Grade 1 - Red students!" They would immediately identify the students wearing red uniforms.

Now, bringing things in the context of CSS:
  1. That outsider is the browser, in which our website is rendered.
  2. The children are the elements
  3. The uniform is the class, and the uniform colour is the class name
The "red" color was given to multiple students to identify them as students of Red Grade. This was to tell the browser that hey these "elements" are the red ones and these are the blue ones; otherwise the browser would not know. From this we derive the following points:
  1. A CSS class is assigned to multiple elements - just like the uniform
  2. A CSS class is used for grouping similar elements - just like students of a particular grade
  3. Without a CSS class, you cannot easily handle multiple related elements
  4. Similar elements must be given the same class (Red Uniform for Red Students)
Understanding the role of the CSS ID in this example is really easy now. Every class has its own monitor or prefect. If that same outsider guy is now asked "Hey Outsider, identify the monitor of class red!" The outsider will say, "No. I cannot!" Why? Because, although the children are classed with red and blue, the monitor is not identified with anything in particular.

The management now decides to assign the monitors with their unique badges, so that if we ask the outsider "Hey Outsider, please identify the monitors of each class", the Outsider would now blissfully respond in affirmative. Now, in the context of CSS ID, we derive the following points:

  1. A CSS id is assigned to only one and unique element that repeats one time - just like the badge
  2. A CSS id more specific than CSS class, which means it has more preference in most matters
  3. A CSS id cannot be assigned to multiple elements

Comments

Popular posts from this blog

Design Organized Website Structures

When developing a website, you must proactively decide its structure before starting the coding. But what does the Web Structure mean at the very first place? Website Structure can be defined as follows: When you talk about the structure of a website, you are talking about its components , their working , their location , their inter-dependency , and their interaction with the user. The design of the Website Structure does not include code. Generally, the design includes, wire frames, sketches, mock ups, lists, flow charts and other visual aids. What is a component? Well, it can be defined as follows: Components are the useful or functional parts of a website Every component has a particular purpose and function. For example, navigation bar of a website has a purpose of providing navigation links to the user. But some, components are versatile and have multiple purposes. For example, a header of website can contain a navigation bar, a search bar, a login form...

Learning JavaScript for Web Designing

There was a time when JavaScript was only used for handling events on the webpage. Front-end developers were more interested in learning tables and CSS for designing the layout of the websites. Today, the trend of designing and developing website is a lot more complicated, quick and advanced. Website is no more a static representation of media and content; it is more of a platform where users are interacting with the content, exploring the information, analyzing their businesses; this turns even a simple website into a web application. Achieving this level of engagement and functionality requires not only the skills of  HTML and CSS but also JavaScript. Now, the Jacks of this trade knows that we are not directly using JavaScript, we use frameworks and libraries to design and layout the structure of the websites. One of the most widely used frameworks is Bootstrap, which requires jQuery as its library. JQuery is a JavaScript based library that has created pre-built functions and...

Web Development includes Websites, Web Apps and Mobile Apps

A few years back, 'Web Development' term was used for the process of developing a website. This was when web development just started to gain popularity. However, with the growing need of having browser based experience within the applications, developers started a new venture called web applications. The reason for its popularity was quick development, increased manipulation of media and content, and of course the aesthetics. Despite of its popularity, security remained its main concern for the data-critical organizations. After a while, developers managed to flawlessly handle the security concerns of the organizations. During this time span, Web Development semantically comprised of both website and web application development. During the past few years, into this group joined another term called Mobile Apps. Just recently before this addition, native apps was widely looked for, but now organizations have realized that the power of a native app is achievable in lesser cos...