CSS basics.
What is CSS?
- CSS stands for Cascading Style Sheets
- CSS describes how HTML elements are to be displayed on the screen, paper, or in other media
- CSS saves a lot of work. It can control the layout of multiple web pages all at once
- External stylesheets are stored in CSS files.
- CSS is used to define styles for your web pages, including the design, layout, and variations in display for different devices and screen sizes.
- CSS handles the look and feel part of a web page. Using CSS, you can control the color of the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, etc.
- CSS saves time − You can write CSS once and then reuse the same sheet in multiple HTML pages. You can define a style for each HTML element and apply it to as many Web pages as you want.
- Easy maintenance − To make a global change, simply change the style, and all elements in all the web pages will be updated automatically.
- Global web standards − Now HTML attributes are being deprecated and it is being recommended to use CSS. So it's a good idea to start using CSS in all the HTML pages to make them compatible with future browsers.
- Platform Independence − The Script offers consistent platform independence and can support the latest browsers as well.
- ID’s are unique
- Each element can have only one ID
- Each page can have only one element with that ID
When I was first learning this stuff, I heard over and over that, you should only use ID’s once, but you can use classes over and over. It basically went in one ear and out the other because it sounded more like a good “rule of thumb” to me rather than something extremely important. If you are purely an HTML/CSS person, this attitude can persist because to you, they really don’t seem to do anything different.
Here is one: your code will not pass validation if you use the same ID on more than one element. Validation should be important to all of us, so that alone is a big one. We’ll go over more reasons for uniqueness as we go on.
- Classes are not unique
- You can use the same class on multiple elements.
- You can use multiple classes on the same element.
Any styling information that needs to be applied to multiple objects on a page should be done with a class.
- There are no browser defaults for any ID or Class
Adding a class name or ID to an element does nothing to that element by default.
This is something that snagged me as a beginner. You are working on one site and figure out that applying a particular class name fixes a problem you are having. Then you jump over to another site with the same problem and try to fix it with that same class name thinking the class name itself has some magical property to it only to find out it didn’t work.
Classes and ID’s don’t have any styling information to them all by themselves. They require CSS to target them and apply them to style.
Comments
Post a Comment