Noob HTML question

when typing in HTML since
is required to break a line, is it okay to use “enter” to stop the code from going off screen so I can read my

</> without scrolling back and forth, or is that not industry standard?

You can. Usually the best practice is to be consistent across your project’s files. Developers often break lines when reaching 80, 100 or 120 characters.

You can automate this with tools like Prettier. Maybe you’ll find this interesting: https://prettier.io/docs/en/options.html#print-width

Last thing, about your favorite editor:

  • you probably have something to wrap the word, in VSCode it’s in View > Toggle word wrap.
  • if you move the sidebar to the right hand side of your screen, you’ll find it easier to navigate the code. Because your code won’t shift from the left to the right when show/hide the sidebar.
1 Like

Thank you very much. I just started last week and downloaded VSC two days ago.

Speaking of that, I am practicing adding links to this and the first time I typed href="" it gave me a drop down of files on my computer. However, I haven’t been able to duplicate that. Any ideas.

Assuming I doing this all wrong.

TIA for any suggestions
Vince

:+1:

If you can’t reproduce the bug, you can’t solve it!

Documentation about links: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

Sorry I’m afraid I wasn’t clear about my question (I’ve studied that link earlier today, ironically).

When I was writing code on VSC the first time, I typed

<a href=""

and, with the cursor in middle of the two " " - a drop down appeared showing files from my computer so that I was able to just click it and the link filled in.

However, that only happened the first time (the exercise was to add 3 links).

So that was what I was trying to find out- how to get the drop down automatically?

TIA

Ok!

You can put the cursor again between the double-quotes.
If nothing happening, type a dot “.” and the dropdown should appear (because “.” means “this folder”).
If nothing happening again, delete the two double-quotes and type them again.

Thanks, but neither worked.
I type href="."; then I just tried href=. and got a drop down for “emmet”, but never the original.

Quick side question… can you use single apostrophes (i.e. href=‘http’) or do you always have to use quotations “http”… came up as I was adding “prettier” formatter to VSC (because ( could see where it put beautify).

Thanks again

In HTML, you can use single quotes (’) and double quotes ("), there’s no difference. The best is to pick one and stick to it (consistency, always).

Note: if you’re working with other languages, single quotes and double quotes can have different behaviour and you’ll may want to do a different choice (PHP for example).

Happy coding!

I want to develop habits that won’t have to be broken later. And I plan on learning javascript 1st (for obvious reason), then react & redux. Then python when I move on to backend. I’ve googled them all and it seems that they agree that the important thing is consistency. For speed of typing ’ works better for me, so Thanks once again.

1 Like