How to keep track of every id and class in html? | SoloLearn: Learn to code for FREE!


How to keep track of every id and class in html?

Let's say I have a big (200+ lines of html/css) code. I have to give a lot of id(s) and classes. How to properly name everything so that you remember what is that certain html element id/class? (I've been naming things like... name1, name2, nameA, nameB, but it gets confusing because of the numbers, letters, or similarity.

2/12/2020 9:41:06 PM

💜 Alex Tușinean 🍇

9 Answers

New Answer


Using name1, name2 etc will be confusing . but you can do this 1. Use real names for your Id, if there's an input that saves value, then the id should be "input_save_value" and if there's another that remove data, then it could be "input_remove_data" using the same syntax by starting every related tags with their tag names or 2. Open the site on your browser, click on the element directly and inspect


name them according to their function or purpose. use long names to describe them precisely, keep whatever naming convention you chose consistent across the whole code. group similar parts of your code in blocks. sketch a design of your page before you start writing it... etc.


Ko given the right one. use real time name instead of code name if they are multiple use add number to it's suffix... Can understand what I am say?


Just give a comment section in each id or class


Personally I always name classes after the utility it provides. For example: If I have a div-element that contains multiple buttons that perform actions with my content, I'd name the class "action-container". Furthermore I would refrain from using id's. while they give you a lot of utility for stiling individual elements, they also lead to a lot of duplicated css properties.


just use real name


It's all about the design. If you have a large complicated piece of software you should create a design document for it. It doesn't need to be as complex or detailed as a formal design document but you should create something. Even if it just rough notes in a notebook. Unified Modelling Language (UML) is excellent for classes and their interactions. If you have complex page layouts then create mockups. These can be as simple as sketches on paper with <div> regions marked with highlighters and <id> annotations next to their associated objects. Software development is as much about project management, design and organisation as it is about syntax. Some would argue the syntax is irrelevant. If the design is bad or none existent then the project is doomed to failure regardless of the language it's implimented in. Unless you're writing simple throw away code.


Japan phone number list have included here 300K consumer phone number list with full details. We provide all valid and updated consumer phone number list from Japan with cheap rate. If you promote your business in the Japan then you can buy this Japan consumer phone number list here. You can get here cell phone number, contact name, address, city, etc. So you can buy this Japan phone number and develop your small business.