Thanks for solving my last problem. I have a new issue that puzzles me.
Inside a div I want to have a colored bar over the full width. Inside this bar I have some text. That text should be to the left with some margin.
It is that margin that gives me a problem. I try to assign it with padding-left. It works for the text. Unfortunately a side effect is that bar grows with the size of the padding and now goes over the boundary of the enclosing div.
What am I doing wrong?
The code I have is:
<div class="subBar">My Text</div>
div.subBar
{ width: 100%;
height: 28px;
margin-top: 20px;
font-size: 20px;
text-align: left;
padding-left:120px;
background: #ee7;
}
Doesn't change what it is. And there were margin and padding in HTML already.
I was joking, but since you bit...
Please can someone tell me what is padding?
Padding is inside the box. Margin is outside. Like this.
So basically padding is putting margin around a box...correct?
Also when is <div> tag used ? Is it used when dividing the page
into sections?
So for the padding example your saying the item which is in middle is called padding....correct?
For the div tag I understand it now.
Not really.
There's a yellow box and a red box. The yellow box is inside the red box. If we put padding INSIDE the yellow box, it becomes larger. Content don't go in the padding, the padding is between the borders of the box and the content (the word TEST in this case).
Margin is extra space that's added OUTSIDE the yellow box.
For example, the space between paragraphs on a page, what makes us see them as paragraphs, is margin. Browsers add it by default. It can be a top margin, a bottom margin or both. You can control that margin yourself with CSS.
Play around with it a little and I think you'll get what's what and where it is.
So tell me if I am correct or wrong.
With th first example your basically saying the space between the border of the yellow box and the content in this case it's "test"..... am I correct?
Does this help? Padding is space inside the yellow box and makes it larger. Margin is outside the yellow box. It doesn't affect the yellow box's size but may affect the size of a containing box (the red box) since it pushes things away.
Maybe the red box confuses you. Try this instead. A page filled with text and just two yellow boxes, no outer box.
I think I understand the second example better. So basically the padding is between the content (padding) and the border of the box . All that yellow color is the padding .
And the margin is outside the box and the text around the box
How about now? Did I understand it now?
Yes, I think you did.
Thank you so much for being patient with me and explaining it to me. I really appreciate it. I am not that like others how they understand at once. Some things I do and some it just takes time for me to understand. In this regard you have helped me so much. I also hope that of if I have any more questions for html you will help me understand it
You are welcome. Of course you can ask more questions.
What is the difference between java and javascript?
I may add that there is no connection between the two. When JavaScript was created Java was the cat's meow. So the name was borrowed to make JavaScript sound hot. It's sometimes believed the JS is some kind of light version of Java, but that's not the case.
deb1, since I pestered you with that yellow box, I just want to show you how to use both margin and padding to make it look nice, a more realistic example. Say, in that page with lots of text we want some info boxes for side notes or something.
If we give the box some padding on all sides so it looks nicer and the text in it is easier to read. Then we give it some margin on the top, right and bottom sides so the text around it doesn't run up against it.
can some one please tell me why div tag is used in this coding?
<!DOCTYPE html>
<html>
<head>
<style>
div{
border: ........;
background-color: ......;
padding top: .......;
padding-right: .......;
padding-bottom: ........;
padding-left: ........;
}
</style>
</head>
<body>
<h2>...</h2>
<div>.........</div>
</body>
</html>
nah you never pestered me . its actually the opposite . i have been pestering you since yesterday and still am
No, not without the context. Could be a good reason for it, or a bad one. Seeing the DIV has neither class or ID and the styling goes for any DIV on the page, I guess the reason is bad. Or is this some kind demo?
so JS is mainly used within html document... correct ?
can you explain why div tag is used in this example please.
<!DOCTYPE html>
<html>
<head>
<style>
div {
border: 1px solid black;
background-color: lightblue;
padding-top: 50px;
padding-right: 30px;
padding-bottom: 50px;
padding-left: 80px;
}
</style>
</head>
<body>
<h2>Using individual padding properties</h2>
<div>This div element has a top padding of 50px, a right padding of 30px, a bottom padding of 50px, and a left padding of 80px.</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
div {
border: 1px solid black;
background-color: lightblue;
padding-top: 50px;
padding-right: 30px;
padding-bottom: 50px;
padding-left: 80px;
}
</style>
</head>
<body>
<h2>Using individual padding properties</h2>
<div>This div element has a top padding of 50px, a right padding of 30px, a bottom padding of 50px, and a left padding of 80px.</div>
</body>
</html>
can you explain why div tag is used in this example please.
but why use div in the style section? i thought div tag is used to group things together?
That example also looks like a demo.
ahh ok. understood . thank you again
I added an example for you above, but you answered quicker than I typed, so I moved it here.
Take this and look at it in a browser. Or I think you can imagine how it will look.
so the second code is for CSS ...right?
the first code is for html ...right?
Yes. You have to paste it together yourself this time.
About HTML and structure. HTML isn't only for browsers such as you and I use. Say for example that a blind person has a page read aloud to them by a screen reader program. That program sees the Ps, headings and so on and make a slight pause before it continues. If the page was made from styled SPANs it would just babble on and it would be pretty tiresome to listen to and make sense of.
So one can see CSS as an optional layer. Like if a girl uses makeup to look prettier, she still wants to keep her eyes and nose and mouth and ears and not have just a painted egg for a head.
OK. so first i need to know my HTML very well then i should move on to CSS ... correct?
i also want to create a web page for practice but am stuck on what topic i should do
it on. so can you give me some ideas ?
I just realized something is wrong with the site. Our validator can't be accessed. I'll ask Darin to look into it.
One thing more. It depends on where you pick up your HTML knowledge if you need to know this or not, but in HTML 4 a lot of elements and attributes are deprecated. In HTML5 I think they are gone, at least most of them. Deprecated basically means they are allowed under some circumstances but shouldn't be used. One could say they all have to do with styling. Colors, sizes, fonts... We should use CSS for all of that now.
So let everything look as it wants. Don't use the FONT tag, change colors and so on. You fix that later when you add CSS to your page. Just think about what elements mean, what they should be used for. If you want a paragraph you use P and not a DIV followed by two BR tags for example.
You can find a list of deprecated elements here. It's the ones marked with a "D", the column labeled "Depr."
http://www.w3.org/TR/html401/index/elements.html
And attributes here.
http://www.w3.org/TR/html401/index/attributes.html
It's good to know them, even if you don't use them you will encounter them.
can you explain to me what is iframe?
after i create a basic web page on a topic which choose can you comment on it when i put it on here . Comment like how i can make it better etc.
I know I answered this. Must have forgotten to hit the submit button. Oh well.
Yeah, sure we can look at your page.
Iframe... Do you know what ordinary frames are? That's when the browser window is split in several smaller windows with individual scrollbars and different documents are loaded in each frame. Frames were popular once. Those of us that know better always frowned upon them though.
https://www.htmlhelp.com/design/frames/whatswrong.html
IFRAME is an embedded frame. IIRC the name stands for Inline Frame. You use it in an ordinary HTML page with HEAD and BODY and it can be mixed with other elements, like P and headings. Whereas "real" frames need sort of a master file that specifies the number of frames there will be, how they'll be placed and how they will be used.
Nowadays I think iframes are mostly used for ads. I don't think you want one on your page.
Great I am doing my Web page on computers
Good luck and have fun!
how can i send the file to you ? i am new on here so have i have no idea how to send files here
You can attach the file to your post. It's a two step process.
Under the field you type your post in there's field labeled File Attachments with Browse button. Use the Browse button to find the file on your hard drive. Then click "Add This Attachment".
That makes the file name appear in a list below the Browse button. There are also two buttons, Remove and Add into Post. Click on the latter and the file will be added.
Or you can just paste the HTML into your post. Use the button above that has a hash sign (#) on it to insert CODE tags around it and it will display nice.
Please check my coding and also see the output in your browser so that you can tell me if everything is OK or if i need to improve on anything . i have also attached the pictures which i have inserted in the coding . so hopefully you will see the pictures in your browser. let me know what you think and if i need to improve on anything.
Attached thumbnail(s)
Attached image(s)
Attached File(s)
computers.html ( 1.71k )
Number of downloads: 84
check this and let me know if need to improve on anything
Attached File(s)
website___Copy.zip ( 118.3k )
Number of downloads: 92
You've done good. Looks like you get it.
You have a few errors though. You can upload your file here and see for yourself.
https://validator.w3.org/#validate_by_upload
You have made three mistakes, some of them repeated, but basically three errors.
Images must have an alt attribute. The value of that replaces the image if the image for some reason can't be loaded (it's printed on the page), so most often a description of the image isn't the best choice. If the image is purely decorative you can use an empty alt attribute, alt="". That makes screen readers just skip the image.
You have a whole page about alt here: https://htmlhelp.com/feature/art3.htm .
Then you have spaces in a file name. That's fine, but URLs can't contain spaces. They must be replaced with %20. Like this.
Just a tip. I would use width and height attributes for the images. Yes, that can maybe be seen as presentational, but it helps browsers to draw the page. You've probably seen large, image heavy pages where the text rearrange itself as the page loads. It doesn't look nice. If you have width and height in the image tags the browser reserves space for the images and the page isn't redrawn, the images just fill in.
With just a few and not too large images and today's fast connections this won't be noticeable. But I think it still is a good habit to use width and height.
so the only comment is put width and height in the images ?
Yup. And correct the errors.
i didn't understand the errors . Can you please explain it to me
I thought I already did above. What don't you understand specifically?
You said i should fix the image and the errors. The image thing i understand . the part which you said that i should fix the errors also... that's the part which i don't understand . i also put it in that link which you suggested but didn't understand their explanation.
But I told you about the three errors above. That you shouldn't use CENTER, that you can't have spaces in URLs and that images must have an alt attribute.
The CENTER tags - just delete them or replace them with DIV.
The alt attributes, well, add them. There's a bit about that here.
https://htmlhelp.com/reference/html40/special/img.html
Spaces in URLs, I don't think I can say it differently than I did above.
The validator complains about a few things more, but you can leave that for now.
Can you please be specific which url you are referring to?
I was. The one to the image with a name consisting of two words with a space between them, 'desktop computer.jpg'.
Maybe you didn't understand that's an URL because it's just the file name. But it is when used in the image src. It's called a relative URL. That it's just the file name means the image is in the same folder as the HTML file. It works the same if you link to another HTML file or anything else. More about how relative URLs work when the the other file isn't in the same folder here: https://htmlhelp.com/faq/html/basics.html#relative-url .
So then can I write like this:
<img src="desktop_computer">
Off course, because if I don't name the file the same way then the image won't show .... correct?
Thank you so much for explaining things to me twice sometimes. I appreciate it. The things wich i have learnt
so far well its mainly from you. You explain things in such away that it just makes it easier for me to understand. So
Thank you
Thank you. That was nice to hear.
Right. The file name must be exactly as it is in the URL. Even the case. Unlike Windows most other OS are case sensitive and servers often run on Linux or some other Unix based OS = case sensitive.
Did you understand the other two errors then?
Well you said there are three errors which are:
1) in the url there shouldn't be any space. It should be like
this: <img src="desktop_computer.jpg">
Also the file name has to be like this also.
2) the second error is I should put width and height for the image
which I didn't do.
3) third error is I put <center> tag before the image which I shouldn't
have so I have to delete that.
Now tell me, did I understand everything? :
Well, #2 was just a recommendation, from me. The third error was that you don't use alt attributes with your images and that's a "must".
can you please explain why not to use alt in the img?
because i thought alt describes the image .
I did explain it. I'll try to elaborate.
Sometimes people won't see your images. Maybe they use a browser that don't show images, maybe they are blind and have a screen reader read the page to them. Or maybe the visitor isn't a person, maybe it's a search engine bot. Or maybe something is just wrong and the images don't load.
If we take the case with the screen reader, IIRC it will read the file name if there is no alt. Not fun to listen to. If there is an empty alt, alt="", it will just skip the image. If there is an alt text it will read that.
I admit that with your images maybe kind of a description is fitting, but at least don't describe how the picture looks in detail, like "Black laptop on a grey table". Maybe "Laptop computer" is enough. People that use text browsers are often offered to download images and if they don't know how a laptop looks, they can then choose to download the image and view it on their computer.
If we take something easier, say you have a linked image of an arrow that means the visitor should click the arrow to go to another page that's described in the text. The best would be to link the text that describes the page the link leads to and give the arrow an empty alt. The next best would be to use alt="Go to page about xxx ". The worst and totally pointless would be alt="Green arrow pointing right".
so in my image can we say alt="laptop computer" ...... that will be enough?
Yes, I think so. I find it hard myself to come up with good alt texts for this kind of images, but that's probably what I would use.
Sometimes you may use images just to make the page pretty. Say you write a page about stars and planets. You sprinkle little star gifs all over the page because you think it looks nice. They should definitely have an empty alt. No one wants to hear or read star, star, star, star a zillion times.
On the other hand images may need a detailed description. Say you write about how to take care of your car with illustrative picture. Then very detailed descriptions of the pictures is probably in place, like "How to loosen the bolts that hold the carburetor with a wrench". If a wrench is what you use. I wouldn't know.
i understand. as i said before you explain very well
Thanks. I added some more above.
I think you can find better guidelines for how to write good alt texts if you google.
One more though, take the WDG logo at the top of the pages here. It uses the alt text "The Web Design Group". That's what interesting with it, what it represents. Often people use something totally meaningless like "logo". Or start to describe what the image looks like with the globe and the cog. That's not interesting for an image like this.
So the problem with alt text is that it depends...
I just remembered a trick with repeated images that's somewhat useful.
Continuing the stars and planets theme... Say that you instead of a gif of a drawn star use a real but small image of the planet Pluto. Then you could use "The planet Pluto" as alt text for the first image, but leave the alt blank for the following 57 copies.
i have just created a basic html form . can you please check if everything is OK? . Later on i will put the CSS in it also .
for now please check what i have attached
Attached File(s)
form2.html ( 610bytes )
Number of downloads: 86
i have fixed the errors etc so please check it again for me . The file is called "computers"
i also created a basic html form . will add CSS style later on.
Please check both the files and tell me if it is okay or if i need to add or change anything.
Attached File(s)
website.zip ( 118.69k )
Number of downloads: 97
????
Okay very sorry for disturbing you
Okay very sorry for disturbing you
Please check both, and let me know if there is anything to change or if everything is okay.
For the computer page i fixed up what you suggested . so please check it now . Also for the form
i put it in the link and fixed up a few errors . so please check now and let me know.
Attached File(s)
website.zip ( 119.3k )
Number of downloads: 79
The computer one looks fine now.
Except the images still use CSS for width and height and they are distorted because you don't use the true dimensions. These aren't errors. You can use any width and height you want, but if the aspect ratio differs from the image's it will look ugly. And CSS is perfectly OK. But it won't make the page load nicer, as I talked about.
The form page lacks HEAD and TITLE. Both are required elements. You found the typo with the email id though.
for the image i dd what you suggested for the width and the height it turned out huge ...... so that is why i didn't apply it . You try it in your browser and tell me . please .
i also fixed up the things which you told me that i should add like header and the title. so please check it .
Attached File(s)
website.zip ( 119.32k )
Number of downloads: 89
can you give me a graphic program which i can download it for free from the internet
IrfanView does resizing but is not a full-fledged editor.
https://www.irfanview.com/
You can find oodles more through a search engine or some freeware site.
when creating a form in html does header tag and tittle always have to be there or is it just an optional ?
It has nothing to do with the form. HEAD and TITLE are always required, never optional.
I've been using GIMP for years. It's a free image editor.
Thank you darin
So Pandy, tell me is this right, the very basic structure for html :
<DOCTYPE HTML>
<html>
<head>
<title>...... </title>
</head>
<body>
..........
..........
</body>
</html>
The places where I said "........" is where the text will come.
So tell me is this correct for the very basic structure of HTML?
Yes, it is.
OK. you see i want a job in the html/CSS line so what kind of interview questions will the interviewer be asking ?
No idea!
please check the file which says computer drives
Attached File(s)
website.zip ( 119.96k )
Number of downloads: 83
??
The zip seems to contain an empty folder?
now check . let me know what you think about it
Attached File(s)
website.zip ( 119.96k )
Number of downloads: 85
Let's see what the validator says.
https://validator.w3.org
For error 4, error 8-11 your saying that i have duplicated the whole HEAD section with style block and all after the External Hardware heading.
well can you show me how to make multiple separate tables on the same page please?
OK so if i did it the right way then what should i do with the error ? should i just ignore it or should change something ?
if i need to change something can you tell me what it is please.
You should remove the duplicated stuff that doesn't belong in BODY.
Like what.... give an example from what should be removed but still give the same output please
I did. The the whole HEAD section and the start tag for BODY you have after the headings.
can you fix that in my file and send it to me . please . it will make it
easier for me to understand. please
Please check the file which says computer drives. i have fixed the errors can you please check if it is okay now. if still not then please let me know what to fix
Attached File(s)
website.zip ( 133.12k )
Number of downloads: 69
You've fixed the errors about the duplicated HEAD in BODY, but some of the other errors remain and you have some new ones. Some about about spaces in URLs. We talked about that before.
Then you have forgotten the closing tag for A in several places. For example here.
A tip for you. Fix errors before you add more content.
Write a basic page with just doctype, head, body and a line of text. Validate. If that's good, add a little bit more. Validate again. And so on. That is validate often and fix any errors before you go on.
spaces in the URL .... what does that mean ? can you point out where the space is in the URL please?
Same as before with your images. Now it's links. You have spaces in the file names which is OK, only URLs leading to those files can't contain spaces since the space character isn't allowed in URLs.
For example this link. But you have the same problem with all links that lead to files that have more than one word in the name.
So your saying it should be like this:<a href="what_is_a_Cd-ROM.html"> what is a CD-ROM? </a>
Is this correct? If not then tell me where I am going wrong
Yes, if you want. But you must also rename the file the same way.
If I write it like that will the error show?
No, of course not. But the link won't work unless you also change the file name of the html file you link to. If that was what you meant?
for the computer drives it is showing two error still after putting the file into the validator. The errors which are showing i don't understand . can you please explain it to me . please
Attached File(s)
computer_drives.html ( 2.51k )
Number of downloads: 59
I put your page through the W3 validator and got 1 warning. Just add the 'lang' attribute, like this:
Can you explain this error to me because when put the file through this was the second error which was showing.
Error: The character encoding was not declared. Proceeding using windows-1252.
For the first error is it necessary to put "lang"?
The lang thing is a warning, not an error. You can do as you please with that. The character encoding is an error.
The character encoding we talked about when you started to validate. I don't use it myself, because it's better declared on the server (for my purposes), in what's called a HTPP header. I also thought we could save that a bit since it also involves with what character encoding the document is saved if you use a single non ASCII character and I thought you had enough on your plate for now.
okay agreed. so the file is okay now?
can you tell me anyway what the character encoding will look like in a html program please.
can you give an example of t please.
See here.
https://www.w3.org/International/questions/qa-html-encoding-declarations
Yes, in my eyes the document is OK for now. You can deal with the language and encoding stuff later. It's of no importance until you publish or share your work. Just remember that you should at some point deal with it.
Errors that you don't expect should always be fixed. But it can be OK to save errors you are aware of and understand why you get for later. Sometimes even for ever, as long as you know what you do. Not everyone would agree with me though.
Sure.
The validator is always right. It's fine.
Yes, of course. There are no errors.
You should never use CENTER. It belongs to those deprecated elements we talked about. They are allowed in what's called HTML 4.01 Transitional, but not in HTML 4.01 Strict. HTML 4.01 came in two versions, just so those things could be phased out. In HTML 5 they aren't allowed at all. They should be replaced with CSS.
Italic is still allowed as far as I know. But it has another meaning in HTML 5, on top of making the text italic. Personally I think this is a little peculiar. Depending on why you want italic text it might be better to use EM (emphasized text) or just use CSS to style that part with italic.
ARTICLE is a new element, introduced in HTML 5, so it certainly is allowed. It must be something else that gives you errors for ARTICLE and I.
??
can you please tell me the following coding is correct or not .
<!DOCTYPE html>
<html>
<head>
<title>....</title>
<style>
table,th,td{
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th>....</th>
<th>...</th>
</tr>
<tr>
<td>....</td>
<td>...</td>
</tr>
</table>
</body>
</html>
can someone please tell me if this coding is correct for creating
a table in html 5?
the "...." means any text will go in there .
It's fine. The validators would tell you so.
https://validator.w3.org/
https://jigsaw.w3.org/css-validator/
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)