How can i add a css code snippet to vs code

41 views Asked by At

is there any possibility to add a css code snippet that contains multiple elements or tags with their styles in vs code.

i already have an idea about the basic way that adds just the properties and values of a single tag or element like this for example:

"reset the css": { "prefix": "resetcss", "body": [ "body { margin: 0}", "$1" ], "description": "Log output to console" }

But Instead i want to add (CSS RESET) as a group of elements and it's styles as one snippet:

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
}

ol, ul {
  list-style: none;
}

blockquote, q {
  quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

Thank You.
1

There are 1 answers

0
BetterReact Developer On BEST ANSWER

Yes, you can create a CSS code snippet in Visual Studio Code that contains multiple elements or tags with their styles. Here's how you can do it:

  1. Open Visual Studio Code.
  2. Go to the Preferences menu and select User Snippets.
  3. Choose the language for which you want to create a snippet(in this case, CSS).

Add the snippet code to JSON file and Save the file. Now, when you type cssreset or whatever you pass as snippet prefix in a CSS file and press Tab, the CSS reset code block will be inserted.

JSON File-

"CSS Reset": {
    "prefix": "cssreset",
    "body": [
        "html, body, div, span, applet, object, iframe,",
        "h1, h2, h3, h4, h5, h6, p, blockquote, pre,",
        "a, abbr, acronym, address, big, cite, code,",
        "del, dfn, em, img, ins, kbd, q, s, samp,",
        "small, strike, strong, sub, sup, tt, var,",
        "b, u, i, center,",
        "dl, dt, dd, ol, ul, li,",
        "fieldset, form, label, legend,",
        "table, caption, tbody, tfoot, thead, tr, th, td,",
        "article, aside, canvas, details, embed,",
        "figure, figcaption, footer, header, hgroup,",
        "menu, nav, output, ruby, section, summary,",
        "time, mark, audio, video {",
        "  margin: 0;",
        "  padding: 0;",
        "  border: 0;",
        "  font-size: 100%;",
        "  font: inherit;",
        "  vertical-align: baseline;",
        "}",
        "/* HTML5 display-role reset for older browsers */",
        "article, aside, details, figcaption, figure,",
        "footer, header, hgroup, menu, nav, section {",
        "  display: block;",
        "}",
        "body {",
        "  line-height: 1;",
        "}",
        "ol, ul {",
        "  list-style: none;",
        "}"
    ],
    "description": "CSS Reset"
}