Can I use my own making tag inside html code? | SoloLearn: Learn to code for FREE!


Can I use my own making tag inside html code?

I have just noticed that if I declare any of my own making selector like "ab" inside <style> tag and then use this tag inside <body> then it's working properly. My question is, is it ok to use these kind of code while making a dynamic website? I am giving you an example. <html> <head> <style> ab{ background-color:red; color:white; font-size:20px; } </style> </head> </body> <ab> This is a sentence </ab> </body> </html> If you play it, it will work properly.

2/14/2020 12:30:56 PM

RH Tasin

6 Answers

New Answer


I am commenting so I could get notifications for someone with the answer. I was wondering the same thing just now!


Kristofer Schultheis Actually you can subscribe to this thread without leaving an answer. Notice the blue star at lower left of question? It is for "following" (and also unfollowing). You can click on that without answering to follow a thread. 😉 Just for extra information, actually its usage is usually opposite: Usually after we answer a question, we will unfollow that thread to avoid being flooded in notification by others' answers, which ain't what we want to read.


Yes it is called custom element it will not cause error but if you have not defined it in JavaScript, it will be UnknownElement and has no behavior, just like a span to define it, the code is like this : (the codes added by me starts from line 57, the above are from Calvin which I kept for reference) For more details, mdn doc:


Martin Taylor Yes, it is a very advanced JavaScript skill to create your own element. Learning custom element used to help in preparing to learn React component syntax. However, since there is React Hooks now, it is less important to learn the component syntax. By the way, I noticed your profile picture, and like to share this drawing by Domino with you:


@Gordon Well colour me pink! I've never heard of that one before! Nice link, thanks.


Gordon thank you very much!