开发者

How would I go about condensing html tags?

开发者 https://www.devze.com 2023-04-01 21:13 出处:网络
I want to condense several html tags into one or just a selection. For example I could turn this: <html>

I want to condense several html tags into one or just a selection. For example I could turn this:

<html>
<body>

Into This:

<mytag>

I just want a clean neat way of using multiple tags at once. Classes would be fine too in fact div classes or something along the lines of that would be good. An开发者_JAVA技巧y suggestions?


You can't define custom tags for HTML, but you can omit some closing tags and even a couple of opening ones. See http://code.google.com/speed/articles/optimizing-html.html or directly the specs http://www.w3.org/TR/html4/sgml/dtd.html .

Note that this is allowed only for HTML and not for XHTML.


With html only this will be hard to realize. You could however do something in PHP, using a template engine like Smarty, where you replace {mytag} with <html><body>.

But by using a template engine, you might as well eliminate the problem you seem to have, 'cause to me it isn't completely clear why you would want something like this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号