Jeremy, a few days ago suggested. I could open up a new thread around to discuss classes and ID and the problems associated with using just ID’s instead of ID’s and Class as the construction attribute in a little more detail and why this would be useful. so without further ado here goes
So to recap for people who are unsure and this is just, so people can see some of the benefits and issues Please note: these aren’t all the benefits and problems for each attribute type, but it does give a quick basic overview.
ID’s are unique- Each element on your page can have only one ID
- Each page can have only one element with that ID
- ID’s can be used in URLs
The advantage for Xway is it can create a style structure that’s based on ID’s, and because it is probably the most important attribute for an HTML item, it can be reasonably sure it’s going to work correctly because each item on the page has a different ID hook… COOL easy peasy.
So what’s the problem with just using ID’s… so to explain that we need to know what classes are good for.
Classes are NOT unique- You can use the same class on multiple elements.
- You can use multiple classes on the same element.
One advantage is if you have multiple divs as inline items within your page and all that’s different is the text within that box, then the construction styles are the same. Technically you could have a 1000 inline boxes all of them with different text but one overall style rather than 1000 styles.
In reality, this doesn’t really happen in the real world, but the main point is it has the potential to reduce the number of what I will call the construction styles.
The other issue is when it comes to a content management system, which duplicates blocks. For example, a div with a chunk of editable text in it a CMS could potentially repeat that block, and if page construction were to rely purely on ID’s, then the HTML would become invalid. (As mentioned in the ID’s section above: you can have only one id of that specific name on the page.
So here comes the crunch to make things a lot easier Xway just like its predecessor Freeway used ID’s as the main attribute for its construction. But going forward that’s going to cause issues (just like it did for Freeway) when it comes to introducing a content management system.
What some of us in the past have done is written actions that basically swop the ID for a class of the same name, and in some actions, we have introduced the capacity to drop the ID completely, add other classes, rename the id etc. The issues I think all of us that have undertaken that task this is that ist BLOOMING complicated to get to work flawlessly. It really is like trying to catch the proverbial horse after it’s bolted out of the gate. Not only does the action have to change the HTML pages naming items convention, but it needs to write to the styles in the head or in an external style sheet and or in a master page, and or within breakpoints. Honestly, it took us months last time along with a colleague of mine to get that action to work and even then there were certain elements it didn’t work on.
Personally, I would prefer to have the ability to choose if something uses classes as its main attribute, no class or id at all or have a class name of my choosing, via the main programs interface. At least that way we aren’t trying to undo a big portion of the program’s output construction, via an action after its all published.
Anyway, it would be nice to have some feedback from some of the others and their thoughts.
All the best Max