简体   繁体   中英

Is there any pure html way to “combine” markup tags into custom one?

I am wondering if I can make something like:

<myTag>myAwesomText</myTag>

While "myTag" is a combination of other html tags, example:

<div class="myClass">
<p>myAwesomText</p>
</div>

Simply the answer is no, this is not possible in HTML.

Usually your text editor (for example Sublime Text) has an option to create snippets where you can customise a shortcut like <myTag> in which custom HTML or any code can be inserted. If you are interested in this, see Sublime Text and Their Snippet Feature

Note: you could also use a functional language like Javascript to create a feature like this

Also, a hacky way of doing something similar to this is creating a custom html element and using css to modify its properties ( although I'm sure this isn't widely supported ):

 mytag { font-weight: bold; color:red; } 
 <mytag>This is bold and red</mytag> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM