Log in

View Full Version : First time in ages and stuck



:.justben.:
08-04-2012, 10:52 PM
The header has a background color but no text why and ino its terrible im really suckish atm idk why :( but please help btw i cant add rep on ipad sorry
<HTML>
<Body>

<html><head>learning to code more</head><body style=
"background-color:yellow;"><h2 style="background-color:red;">of code is memorable"</h2>

</body>
</HTML>

<h1><b>learning html and css</b></h2 style

<p><em>learning css is insanely hard<p>

<HTML>
<Body>

<a href= "http://www.w3schools.com">
This is a learning tool </a>

<HTML>
<body>

<p>the hr / tag adds a horizontal</p>
<hr />

</body>
</HTML>

<p>there other text types like<sub> this</sub>And like<sup> this</sup> the text is <sub> and the second one is </sup><p>

</body>
</HTML>

Tomm
08-04-2012, 11:27 PM
The whole thing is just messed up. You've got the whole basic structure wrong - you don't want multiple <html>, <body> and <head>. Additionally you've got multiple unclosed tags and some tags are just totally incomplete. I think you need to start again from the basics and get the proper structure right to start with.



<!DOCTYPE html>
<html>
<head>
<title>This is where the title of the page goes</title>
</head>
<body>
<h1>This is a header</h1>
<p>Here is some misc. text</p>
</body>
</html>


That is just a really basic page. Note I've not opened multiple <html>, <body> or <head> tags and I've closed all the tags. Also I've placed the title of the page in the appropriate element.

:.justben.:
09-04-2012, 01:37 AM
Was told u need it every new script

Tomm
09-04-2012, 01:52 AM
What do you mean every script? HTML is a markup language, nothing to do with scripting/programming. Regardless, clearly what you have been told is wrong. In a single webpage you don't have multiple <html>, <body> and <head> tags.


Was told u need it every new script

:.justben.:
09-04-2012, 02:13 AM
What do you mean every script? HTML is a markup language, nothing to do with scripting/programming. Regardless, clearly what you have been told is wrong. In a single webpage you don't have multiple <html>, <body> and <head> tags.



So only have
</body>
</html> ?

---------- Post added 09-04-2012 at 02:13 AM ----------

When i finished

Tomm
09-04-2012, 02:18 AM
Look at the example I posted above, I only open <html> and close (</html>) it once. Nested in <html> I only have one <body> and <head> block.


So only have
</body>
</html> ?

---------- Post added 09-04-2012 at 02:13 AM ----------

When i finished

overskrill
09-04-2012, 10:26 AM
First of all, what is your first language? Because your English is quite poor. Secondly, the <html> tag just defines that it's a HTML document, therefore you only need it once. You also use the <body> tag once because well, a webpage with more than one body just wouldn't make sense, would it?

Like the above said, HTML isn't a scripting language so whoever told you this obviously doesn't know what he/she is doing.

Pegle
09-04-2012, 10:50 AM
Because the body is everything you see on the screen (bar the title in the window/tab) you don't have multiple screens for each bit of your website do you?

And in reply to above, if English isn't his first language then he might assume that a HTML document is called a script.

:.justben.:
09-04-2012, 11:30 AM
Ok thanks for helping btw how do i color the background of the header then which was my original question

---------- Post added 09-04-2012 at 11:40 AM ----------

Got it working is this a bit better
<HTML>
<Body>

<html><head>learning to code more</head><body style=
"background-color:yellow;"><h2 style="background-color:red;">of code is memorable"</h2>

<h1><b>learning html and css</b></h2 style

<p><em>learning css is insanely hard</em></p>
<a href= "http://www.w3schools.com">
This is a learning tool </a>

<p>the hr / tag adds a horizontal</p>
<hr/>

<p>there other text types like<sub> this</sub>And like<sup> this</sup> the text is <sub> and the second one is </sup><p>

</body>
</HTML>

dbgtz
09-04-2012, 02:05 PM
If I remember correctly, you're not supposed to put content in the head tags hence why you can do <body style = "css"> but not <head style = "css">. Also rather then repeating the styles, just embed some CSS seperately within the head tags as shown.



<html>
<body>

<head>
<title>This displays on the tab</title>
<style type = "text/css">
<!-- style rules can go here -->
</style>
</head>

<body style="background-color:yellow;">
<h2 style ="background-color:red;">of code is memorable</h2>

<h1><b>learning html and css</b></h1>

<p><em>learning css is insanely hard</em></p>
<a href= "http://www.w3schools.com"> This is a learning tool </a>
<p>the hr / tag adds a horizontal</p>

<hr/>

<p>there other text types like<sub> this</sub>And like<sup> this</sup> the text is <sub> and the second one is </sup><p>

</body>
</html>

Jonster
09-04-2012, 03:02 PM
A quick poorly written lesson:

Starting your document:
To start your document, you must define the documents type and open both the HTML and head tags. The head tag is effectively short for header. You can define the title of the webpage, link or create a stylesheet and so forth. For example:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>My first webpage!</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
</head>


The <title> tag sets the title displayed in the browser, and the <link rel="stylesheet"...> links to an external stylesheet, found in the folder "style" with the filename "style.css". You then close the head tag using </head>.

Adding Content
You will then want to add content to your webpage.



<body>
<h1>Welcome!</h1>
<p>This is my first webpage!</p>
</body>


The above opens and closes the body tag, displaying a heading with a small paragraph.

Closing your document:
Finally, you will want to close the HTML tag, completing the webpage.



</html>


--

You only have ONE: HTML, head and body tag. Your final document should look similar to this:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>My first webpage!</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
</head>
<body>
<h1>Welcome!</h1>
<p>This is my first webpage!</p>
</body>
</html>


Indenting your code will truely help you to follow it too. It is far easier to read and allows you to pinpoint sections.

I trust this will help you.

:.justben.:
09-04-2012, 08:57 PM
The code works so does it rly matter?

---------- Post added 09-04-2012 at 08:59 PM ----------

I do not rly know css im just doing basic html

Jonster
09-04-2012, 10:20 PM
...Of course it matters. You have random tags thrown everywhere, and not to mention that it's extremely poor practice. You will never learn if you consistently do it wrong, so why bother learn at all?

:.justben.:
10-04-2012, 01:36 PM
...Of course it matters. You have random tags thrown everywhere, and not to mention that it's extremely poor practice. You will never learn if you consistently do it wrong, so why bother learn at all?

*Removed*

Edited by Jordan (Forum Super Moderator): Please do not be rude to others

dbgtz
10-04-2012, 02:08 PM
*Removed*

What he's saying is completely true though. What's the point in asking for help if you don't take what is said into consideration and just insult the person who is helping?

Pegle
10-04-2012, 02:27 PM
[2] to the above.

Indenting will help you, because you can see which bits of code are which. It's like using spaces in between words; What is easier to read:

This:
helloiamnotusingspaces

Or this:
hello i am using spaces

Same with indenting.

Want to hide these adverts? Register an account for free!