Delete HTML Elements How can it be done

Tell us what’s happening:

Your code so far


<h1>Hello World</h1>

<h2>CatPhotoApp</h2>

<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<del> Hello World </del>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; rv:66.0) Gecko/20100101 Firefox/66.0.

Link to the challenge:
https://learn.freecodecamp.org/responsive-web-design/basic-html-and-html5/delete-html-elements

Just remove it. Doesn’t require a tag.

Remove the first line

Example:

<h1>Example</h1>
<h2>Hello World</h2>

would simply become

<h1>Example</h1>

The first line is no longer showing, so am a little bit confused on how to remove it

Here is a code example…

HTML

<html>
<head><meta /></head>
<body>
  <h1 id="my-h1">BLAH 1</h1>
  <h1 id="my-h2">BLAH 2</h2>
</body>
</html>

Javascript

// Going to use the removeChild() method
// In this case the parent of the element wanting to be removed
// is the body tag so..
let removeTarget = document.getElementById("myh2");
document.body.removeChild(removeTarget);

// Ta Da the target should be removed

Here are the w3s docs for this method
removeChild Method

You can also use the outerHTML method if you want an example ask otherwise here is the link to the documentation
outerHTML => https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML

Also you can just make the targeted node

h2{
display: none;
}

and that will make it disappear.

Wait this is too much. am still learning with freecodecamp.org so i don’t really know how to put all this in there

Ignore @PioArchiver, they haven’t looked at what you’re asking in respect to. If you’re still having the issue after doing what was suggested (just deleting the line), try reloading the page and deleting the line, and if still not passing then try clearing your browser cache and doing same. If there’s still an issue, post exactly what code you have that will not pass here, it may be a simple error that fresh eyes will pick up straightaway.

@PioArchiver please read what the op is asking (and what other people have written in reply to them) before just banging out a series of incorrect instructions based on only reading the title of the post.

5 Likes

thanks @DanCouper for correcting me, I will from no on.

Sorry about that @chiagozie I didn’t look at the curriculum problem…I assumed it was a mis-worded question about javascript.

(Thought you meant to ask a question under javascript)

2 Likes

Thank you @PioArchiver, for your your contribution, i really appreciate and also thank you @DanCouper, for your assistance.

Hope the best for you @chiagozie, but did you get the problem hashed out?

Not really, I taught freecodecamp.org help like put one in the direction and help them learn coding but it’s still looks kind of hard for me.

I see, well like @DanCouper said, if you post the code you were using to submit your work someone may be able to help you. Mind showing what you have tried at this point.

Probable just a typo, which happens especially when you first start out.

Sorry for being blunt before: I should have emphasised that what you wrote is spot on, really good advice generally (just only if it wasn’t for that specific challenge).

@dancouper, hey no problem. You were right and I shouldn’t of assumed anything, especially for anything programming related, your doing your job as a mod (Tough job, but someones got to make sure answers are up to snuff). I will take it as a learning experience.

I took a closer look at your code and found it “your mistake”…I didn’t catch it at first.

Look at your bottom line, do they tell you to put another element there, or do they ask you to remove an element?

The picture below is a screen grab of what the test is looking for, it doesn’t say to add an element anywhere. (You don’t need to in order to backspace/erase an element manually)
Also, you have to be careful to avoid any extra mark up in your submissions and to follow them to the tee.

In html you never have use a “declarative” method to delete an element and when the instructions tell you to remove an element or add an element they mean manually type it out or to manually erase the element.

image

So the above instructions tell you to

  1. erase the <h1> element at the top of the document
  2. Don’t erase the <h2> element right below the <h1> element
  3. Don’t erase the <p> element right below the <h2> element