HTML & CSS
<p class="title_box"><a href="docs/2011.pdf">Custom Packages</a><hr /></p>
I'm getting an error saying: end tag for element "p" which is not open.
I thought I was closing everything in this line correctly?
( <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> )
With an HTML 4.01 doctyoe it should be coded:
<p class="title_box"><a href="docs/2011.pdf">Custom Packages</a><hr></p>
The /> for self closing tags are only used in XHTML.
Oh ok, I thought it was something with the doc type, I'm new to this kind of stuff.
Since I have a lot of self-closing tags in my website, perhaps I should switch to a different doc type?
XHTML 1.0 Strict?
I want to stay up to date with current doctypes and HTML trends.
Bades, in my opinion it's better to remove the self-closing tags and stick with HTML 4.01 Strict. Stephen, since the <hr> tag is a block element, shouldn't it be outside the <p></p> element?
I decided that XMHTL 1.0 Strict would be best practice top use.
Can't figure out this one though...
Document type does not allow element "hr" here; missing one of "object", "ins", "del", "map", "button" start-tag
…class="title_box"><a href="seminars.html">Training & Seminars</a><hr /></p>
So what am I suppose to do if I want to place an hr here?
Ah you seemed to answered my last post then.
I'll look into the differences of HTML4.01 and XHTML 1.0, and see which one is better or more widely accepted.
Try moving the <hr /> so that it's outside of the </p>
Oops - I spotted the most obvious error in the code and didn't think to check if it was the only one - or the one causing the error message.
Also it has been qute a while since I added a <hr> tag into a page since they are impossible to style consistently across the different browsers so I hadn't needed to think about it being a block tag for quite a long time.
That's why the ONLY time I use HR is for the CSS off or print users to divide up areas -- and then set them to display:none for media="screen,projection,tv" and media="handheld"
I want a divider after a paragraph like that, I pad the bottom, margin the bottom, and use border.
That said, class="titleBox" ?!? Shouldn't that be a numbered heading? (wild guess, I'd have to see the whole section of markup)... as it is that's not enough text to warrant calling it a paragraph.
I've already used h1, h2, on the page, and I've used h3, on a few other pages(I'm using one CSS page)
So I could use an h4, but I heard after h3, that headings aren't really so useful like for SEO stuff. is this true?
If you are thinking about SEO when deciding what tags to use in the page then you are going about it entirely the wrong way.
Use the tags that best describe what their content is. If you define the page with the semantically correct tags then both real people and search engines will be able to understand it better and less SEO will be required.
Felgall hit the bullet points -- in particular the "if you are using a tag JUST for SEO you're probably using it wrong" -- but your wording on "I've already used" makes me ask "are you using them correctly?"
The POINT of heading tags is to say in each section what's a subsection of what -- H3 is the start of a subsection of the h2 preceeding it, H2 is the start of a subsection of the h1 preceeding it, and you should only ever have one h1.
I'd have to see the whole page to say for sure, but so far your wording is sending up warning flags with me.
But I get that way whenever I see things like <p class="title"> or <td class="heading"> -- it's usually an indication someone hasn't grasped how semantics work yet or have giant gaps in their understanding of HTML.
My h1's and h2's are formatted the same throughout the website on each webpage.
I'm also only using one CSS page for the entire website, so when I establish style for the h1 on the home page, the h1 on the products page is going to be the same.
Can you apply id's and classes to headings?
This is completely true, I'm a beginner only been doing this for about 6 months, and everything new site, and every new page has something where I learn more and more about HTML/CSS.
I would say it's almost impossible to learn everything there is about HTML before you start playing around with it, an dI'm learning as I go along.
Also are you guys stating that any time you have a header/title of section of text or whatever it should most likely be within a <h> tag?
For the most part -- yes... either a numbered heading, or the appropriate heading-type tag for the element.
Numbered headings are NOT the only heading type elements in HTML. You have CAPTION which is basically a heading for a table, you have TH which is a heading for a row or column (typically for the column if in THEAD, or for the row if in TBODY -- assuming you use those structural/semantic elements PROPERLY, which of course few people do). You have LEGEND which is the title for a FIELDSET, a grouping of form INPUTS, you have LABEL which is a heading for a form input element like INPUT, TEXTAREA, SELECT, etc.
Oh, and about H1 -- since there should only one of these per page ANY other heading-type element you use on the page is basically saying it's a subsection of THAT... this is why IMHO it should be the first semantic element on the page since by definition EVERYTHING is a subsection of it... and so on and so forth down the list. You make a new heading, the content under that heading should be a subsection of the heading preceding it, with the headings fanning out like a tree.
Basically we're talking semantic markup -- saying what things ARE and NOT how they are going to appear; which also entails NOT using tags with meanings around the wrong elements... two or three words of text is not a GRAMMATICAL paragraph, and if you are thinking a typographical paragraph you are thinking APPEARANCE, which has NO BUSINESS in your HTML. Just because it's text doesn't mean it gets a P around it... and if it's not text, it most certainly should not have a P around it. You see people make that mistake with IMG all the time... only time it would be appropriate to be around IMG would be if said image is inline to the text like a smily
Stephen, there are some wonderfully Byzantine code snippets out there for styling HR elements so they display the same cross-browser. Generally, they're more trouble than they're worth, I think.