Adding url into <a href=""> with Emmet

Runtime Terror picture Runtime Terror · May 12, 2016 · Viewed 8.4k times · Source

Has Emmet a syntax for adding URL into <a href=""> tag?

E.g.:

Syntax:

a:www.google.com

Result:

<a href="www.google.com"></a>

Answer

Joe Clay picture Joe Clay · May 12, 2016

The general syntax for adding an attribute to an element in Emmet is:

element[attr=value]

So in this case, it'd be:

a[href=www.google.com]

That said, if you just do a by itself, it should automatically jump the editor cursor into the href attribute, and you can do a:link to pre-populate it with a http://. So those options might be faster/more to your tastes.

For more information, look at the Emmet Cheat Sheet - it lists all the syntax that's available.