How to automatically write html structure

Viewed 14287

I am using visual studio code .I have the php extension installed already . But it is very repetitive to create each php file with the base structure like this one . Since it does'nt automatically insert it for me .

<!DOCTYPE HTML >
<HTML lang="en">
   <HEAD>
      <TITLE></TITLE>
   </HEAD>
   <BODY>
   </BODY>
</HTML>

Is there anyway or short key to quickly copy this structure into the newly created php file ? without using control+C control+V from a note ?

5 Answers

If you are using VS code then you can use this command shift + 1 and enter to auto-populate HTML Doctype in HTML or PHP.

enter image description here

When you will press enter it will add the following code:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>

  1. press---> Shift+1 + enter or tab

OR

  1. press----> html:5 + enter or tab

Note:- In VS-Code.

Type !, and then click the first snippet in the auto complete. It will generate the default HTML template

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
</body>
</html>

Or, you can use snippet to add your own code, and this should help you

I don't know why. just ! doesn't work for me, but when I type html5 or html:5 and use autocomplition, it works like a charm.

It happened to me also, You can use Shift + ! then tab. (If this is also not working, you might need to make some changes in vs code setting, this is available on the web or on YouTube easily)

hope this helps

For me, it got fixed by itself

Related