Why not always use .Classes in CSS and skip #IDs alltogether?

1 Answer

Answer :

answer:IDs allow you to identify a unique element whereas classes are used for specifying just that, classes of elements. Its an important distinction but I can see how it might seem that it isn’t needed. Personally I find useful for organizing your layouts. It is also very useful for targeting specific elements via JavaScript that require updating without reloading the page as this facility is built into all browsers via getElementById(). Of course there is nothing stopping you from just using classes but then again there’s nothing stopping you from using tables and images for your layouts either. I think its best to remember that CSS is a way of describing the style of HTML and that the two are not necessarily linked as closely as you might think. All CSS does is provide ways to select various portions of HTML for you to modify visually. With HTML, you can specify IDs and classes on elements for reasons other than styling – its a bit like metadata. HTML is just a way of defining a document and properties about portions of it. CSS is effectively an optional layer (but obviously a totally ubiquitous one). If you check out some of the more advanced selectors in CSS you’ll find that it goes way beyond classes and IDs.

Related questions

Description : Does the buttons background color at Fluther.com made with CSS only or it is an image?

Last Answer : answer:It's an image. Fluther uses sprites to compress the amount of image downloading the user does with each page request. If you look at the sprite image the buttons are there. Note that ... If you look at Google using Safari or Chrome, the visual effect is accomplished entirely without images.

Description : Can anyone help me with some CSS?

Last Answer : How is it jumbled? Often for IE i use a second stylesheet and apply it using : < ![endif]—> The first one is your first stylesheet, the second is a stylesheet that only fixes the things that are bad in IE.

Description : What is the best way to learn how to layout your design images using CSS?

Last Answer : I learnt CSS layout in this tutorial

Description : Web Development: Coda vs. TextMate / CSS Edit combo?

Last Answer : I prefer Coda and CSS edit 2. Coda simply appeals to my taste more than Textmate. Coda has built in documentation which I use regularly. But many of it's options, such as bonjour editing where two people can edit a ... . As far as CSS Edit 2, I don't think it really has a contender. It's quite nice.

Description : What song do you insist on keeping in your playlist, but always skip?

Last Answer : Bullet by hollywood undead. As a reminder ive made it past that part of my life when i was in such pain and wanted it all to end

Description : Is makeup primer always a necessary step in makeup application, or can I just skip it?

Last Answer : Makeup primer is not a necessary part of makeup application. It is something that can help with certain problems like dry skin and breakouts, but if you don't have sensitive skin then you don't need to consider it a must when applying your makeup.

Description : Do you still use spaghetti code , like QBasic?

Last Answer : talljasperman Sorry I didn’t know that spaghetti code was a pejorative. My teacher called it that and I did not look it up.

Description : Regulating email use?

Last Answer : What Operating System are you using and do you use a Desktop client for email or a web-based client?

Description : Why use ASP.NET MVC 4 over just HttpHandlers with JQuery Ajax?

Last Answer : answer:I'm not familiar with asp.net, so I'm not sure what it gives you, but a common problem with a single-page app using a lot of jQuery is that it can quickly become unmanageable, especially if ... you other questions, I'm a fan of using only as much as you need and your approach sounds fine.

Description : What does the use of the # symbol mean in XML Document Type Definitions?

Last Answer : answer:

Description : How to use cron in ruby on rails (2.3.5). Please help?

Last Answer : answer:At the UNIX prompt, type man crontab and help documentation will appear. - Crontab is the interface you use to schedule jobs in cron. It launches a basic text editor - usually vi but anything you want - and you enter in one ... . 30 21 * * 3 /path/to/maintenance.sh # #---------------------

Description : Why should I use JavaScript Library if it may effect the performance of a web site?

Last Answer : You might want to check out some extremely lightweight Javascript libraries such as xui, zepto, or jQuery Mobile. However, 17KB should not be a huge concern on iOS and Android devices. On phones with ... .example.com or mobile.example.com with minimal CSS, small page size, and no Javascript at all.

Description : Do any other ask-public users use J (the programming language)?

Last Answer : answer:Interesting. How can it confuse experienced programmers, and how is this an awesome thing? Also, is this one of those languages great for mathematics and scientific computation?

Description : If I already know basic PHP/MySQL, what else should I learn to use Google App Engine?

Last Answer : answer:I am not an expert, I just started reading up on this myself, but here are a couple of starting points on data storage. Rather than a separately maintained SQL database, ... .com/appengine/articles/datastore/overview.html http://code.google.com/appengine/docs/python/datastore/overview.html

Description : Why do the majority of Python packages use urllib2 instead of httplib?

Last Answer : answer:urllib2 is closer to curl. It's closer to a real client-and for many of us, makes much more sense than doing 4 or 5 steps to request an url and read the response. httplib is a lower ... It is normally not used directly - the module urllib uses it to handle URLs that use HTTP and HTTPS.

Description : When to use stored procedure and when function in SQL Server 2008?

Last Answer : There’s no technically right answer here – I think I’d do the SP calling SP.

Description : Will using .NET 3.5 server side for a web site place any notable restrictions on what web browers can use the site?

Last Answer : .NET 3.5 VSTS feature won’t restrict you on any navigation features.VSTS is solely browser independent.You could publish your site on any browser, but you need to do some customization while using firefox.Some addin features are needed to make your Server side setup function properly.

Description : How does one use his mind to create a plan ?

Last Answer : By deconstructing a problem into smaller pieces. I think people intuitively write business rules in their head for all problems. They may not account for all the options, and they may only see the ... but in reality, problem solving comes in the form of deconstructing a problem into Yes/No format.

Description : Which Windows program to use to introduce 6 year old to programming? Best program to teach LOGO or BASIC with graphics?

Last Answer : Get an old machine and load DOS 6.1 on it.

Description : Does anyone use ELGG?

Last Answer : Have you tried using www.ning.com as an alternative. It's pretty simple to use and no coding knowledge is required. It's pretty simple to modify, but you can't change the layout all that much. ... all look a lot alike. I believe you can break the mold and handcode the template in HTML though.

Description : What Kind Of Preset Should I Use On Handbrake?

Last Answer : Honestly, just give it a shot and use whatever preset produces the results you like. You won't ruin your movie or delete your computer or anything. So try all of the ones you have access to ... , and compare the final results, then continue to use the preset that produces the results you like best.

Description : Can I use an RSS feed like this?

Last Answer : RSS is a pull technology, so you are relying on the client to refresh to get the update.

Description : In OOP why would you even want to use an interface?

Last Answer : Because you can then indicate things like this method takes an argument, which can be of any class that implements this interface. It's not for the benefit of the classes that implement it, but ... in this specific sense) are a way of formalizing the contract between the caller and the called code.

Description : Why would a programmer use spaces instead of tabs for indentation?

Last Answer : Because the programmer works with other programmers, some of whom have their editors set to expand tabs to 8 spaces, others of whom have their editors set to expand tabs to 4 spaces, and still others of whom ... use only spaces than it is to get everyone to agree on how wide a tab stop should be.

Description : Can you use JavaScript to force-replace a particular image in the browser cache?

Last Answer : answer:I'm not sure about doing it in js but if you make it so that the image/stylesheet/javascript file in question has a unique string after the filename like '/images/header.jpg?somerandomstring', when ... the string. That way, whenever you deploy a new version, it'll have a new cache string.

Description : How can i use programming to eliminate static in an audio clip?

Last Answer : hmm, fastest thing i can come up with right now is audicity, it has a plugin for it if i remember correctly, you could give it a try

Description : What kinda of code commenting system do you use?

Last Answer : answer: I write bad code. Seriously, that is in stuff viewable be to public. And I comment the fuck out of everything.

Description : Should I use a domain like youstre.am, or mystre.am or will no one remember it?

Last Answer : I think it’s memorable and clever. Go for it.

Description : State the use of OF and DF flags of 8086 microprocessor.

Last Answer : Overflow Flag: This flag is set if an overflow occurs, i.e. if the result of a signed operation is large enough to be accommodated in destination register. Direction Flag: It selects either increment or decrement mode for DI &/or SI register during string instructions.

Description : Salesforce SDK uninstallation from XCode?

Last Answer : Too many variables – only you know your code, how it was written, and how extensible (or not) it was in the first place. I assume you have been to the Saleforce API and SDK pages.

Description : Is there a program where you can identify music in a specific website?

Last Answer : Need Answer

Description : What is a good programming language to make a multiple choice quiz?

Last Answer : Google classroom should work.

Description : Is there a website that shows all the English words, idioms, etc ever invented, including archaic, unofficial, and newest words that have just been invented?

Last Answer : The problem with such a lexicon would be that there have been a lot of slang, dialect, idioms, and unofficial words that 99% of people have never heard of. Besides that, the English language is ... pretty good vocabulary. Hopefully, someone will recommend some. I am unable to do this at the moment.

Description : How can I add HTML markup to this ajax result?

Last Answer : Need Answer

Description : Function or application allowing me to connect or disconnect wifi?

Last Answer : Some routers - Belkins and older Ciscos, had an app that would allow you to remotely-control your router from your phone. You didn't say what kind of router you have, so it's hard to guess. You can ... . Bottom line - you can do this easily if you have a wifi-based power switch and an app. example

Description : How can I become advanced in javascript in 2 months?

Last Answer : Study hard…work hard!!!

Description : Can you help fix this programming problem in Python?

Last Answer : You can’t treat arrays of digits as a single number. The easiest way to read a numeric string is to use the sys library to read a line from the keyboard. import sys print(“Enter value for mass”) mass = sys.stdin.readline() mass = float(mass)

Description : What's the best book for understanding Unity 2D?

Last Answer : Are you a beginner programmer in general, or just new to Unity? That would make a big difference in how I would respond.

Description : Programmers: Is this puzzle a "named problem?" and can you help me with it?

Last Answer : I'd call it enumerating a list of all combinations . There's a field of math called combinatorics which I did not study but I assume probably has a word for this. It doesn't seem like a puzzle ... each iteration, and tweak it to get the output format you want, but that's essentially it, I think.

Description : How do you get the link posted and not the updated page?

Last Answer : You don't have control over it. The URL that you referred to today is pointing to a page that is housed at a server somewhere else. It isn't under your control or Fluther's - it is under the control of ... a month or a year ago. Summary: it isn't under your control. You get the page they send you.

Description : I'm looking for a IT Project Idea for my Final Year. Can anyone suggest something?

Last Answer : How to maintain a question and answer site with trolls, spammers, and questions that violate the guidelines?

Description : How can i improve my skill sets?

Last Answer : You didn't say what you already know, but my main recommendation for something to learn is Python. It's a great learning language, it's free and easy to install, there are great ... and relatively easily. https://www.python.org/about/gettingstarted/ https://www.programiz.com/python-programming

Description : What should I study in order to write/program a career search software?

Last Answer : More programming. And logic. You need to understand how to develop a search for terms, and then also determine where to search, and then how to optimize search results in a relational database.

Description : Is it on all smartphones you can't post a link?

Last Answer : I can’t cut and paste easily with a smart phone. I could type the link by hand. I would have to write it to a pen and paper first and it would work. If I really need too I could boot up my new chrome book and make a link.

Description : How much work does it take to change on a program, from "Monday to Sunday" to whichever 7 days in a row?

Last Answer : It would depend on the individual program.

Description : What coding languages or other courses should I take on CodeCademy?

Last Answer : The courses that I’ve taken I feel are really only useful for Web design.

Description : How do I simply repeat a line of code 4x in Javascript?

Last Answer : something like a for loop is pretty simple, and gives you a handy counter if needed. for(var i = 0; i < 4; i++) { forward(); }

Description : Programming a NEMA 17 stepper motor to microstep with an Arduino?

Last Answer : There are literally thousands of arduino code examples out there. This is something you should figure out on your own because the act of doing so will make you a better tinkerer. A typical stepper will have like ... digital I/o pins to output the step sequence. Even an uno or mini pro will do that.

Description : Programming a stepper to have a "home" position?

Last Answer : Obviously it would need some way to sense or establish its location, or possibly to move or grope about to establish its location. And it could be good to have some logic for noticing when its assumptions about its environment are wrong.

Description : How to become a Game Developer?

Last Answer : There are really two separate questions (or skills) needed here. 1) programming technique. Have you been a programmer; have you developed software before? That's a skill unto itself Programming for a small ... . I can't give you a better answer, because there are so many options to choose from.