+ 8

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.

14th Feb 2020, 12:30 PM
RH Tasin
RH Tasin - avatar
6 Respuestas
+ 5
I am commenting so I could get notifications for someone with the answer. I was wondering the same thing just now!
14th Feb 2020, 12:32 PM
Kristofer Schultheis
Kristofer Schultheis - avatar
+ 4
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.
15th Feb 2020, 1:53 AM
Gordon
Gordon - avatar
+ 3
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 : https://code.sololearn.com/WpM7Lm6fFDgI/?ref=app (the codes added by me starts from line 57, the above are from Calvin which I kept for reference) For more details, mdn doc: https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements
14th Feb 2020, 1:08 PM
Gordon
Gordon - avatar
+ 3
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: https://code.sololearn.com/WzGIADYzj0EX/?ref=app
15th Feb 2020, 1:51 AM
Gordon
Gordon - avatar
+ 2
Gordon thank you very much!
15th Feb 2020, 1:57 AM
Kristofer Schultheis
Kristofer Schultheis - avatar