[SOLVED] Merge element, tag and attribute. Beginner question

[SOLVED] Merge element, tag and attribute. Beginner question
0

#1

Hello,

I am learning HTML and have troubles merging a element with a tag.

I have a input tag type=“text” and have to nest a form element inside.
The task: “Nest your text field inside a form element, and add the action=”/submit-cat-photo" attribute to the form element."
If I understand the task correctly I have to combine this two together:

<input type="text"> 
<form action="//submit-cat-photo "></form> 

If I try to do it, it loos like this:

<input type="text" form action="//submit-cat-photo " </form>

Like you see I cant really combine elements and attributes. I can work with paragraph and anchor in one line though.
I don’t know if I can share the link, but this is the task:
https://learn.freecodecamp.org/responsive-web-design/basic-html-and-html5/create-a-form-element

Thank you very much.


#2

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

What you have written is not nesting. A nested element example is as follows.

Let’s say I have a div element and I want to nest an h1 element. I would write the following code to do that:

<div>
  <h1>This is an h1 element nested in a div element</h1>
</div>

You will notice the “nested” element is in between the opening and closing div tags. You tried to put the form element inside the input element tag like an attribute which is not correct.


#3

Thank you for improving readability of my text. And thank you for explaining me the concept of nesting.