<li><a>... or <li><p><a>

:rofl:

That is a PERFECT example of when STRONG, P and LI are ALL semantically incorrect… Since you have an apparent HEADING and CONTENT…


<h2>
  <a href="#">First name</a>
  Message title lorem ipsum
  <span>12.02.2010</span>
</h2>
<p> this would be the first paragraph of the message. maybe a teaser of the article... btw why would you put a link to the name and not the title.. but whatever</p>

NO LI, NO P around the OBVIOUS heading… Of course you’d want the APPROPRIATE level heading depending on the code around it… and if you really need a wrapper to divide them up, DIV would be more semantically correct since it would NOT be changing the meaning of or applying unnecessary meaning (like say… list item) to tags that already have perfectly good meanings of their own!

Say what things ARE… that’s a heading to a section of content, USE a heading tag… Heading tag starts a new subsection, so you don’t need to apply any extra semantic meanings to it by wasting code on a UL/LI – or worse, applying the wrong meaning to it.

Which is one of the few times I disagree with Ian – those are NOT paragraphs in the grammatical sense, so there is NO reason to be wrapping them in paragraph tags. That’s wasteful/pointless markup applying a semantic meaning to elements that already have a perfectly good meaning on them.

Those meanings being LABEL and INPUT. They say what they are, you don’t need to say more!

It’s one of the few cases where <br /> would actually be a more accurate approach to handling it.

Assuming it’s a proper form with a block level parent like FIELDSET in place.

People heard ā€œsemantics means using Pā€ and that’s it, and just started slapping them around all sorts of elements for no good reason – just like the die hard ā€œtables are evil never use themā€ nutjobs who then go out and abuse nested lists and endless DIV on obviously tabular data.

An Image is NOT a paragraph – PERIOD!. A heading is a heading, NOT a paragraph and a strong tag – PERIOD! A list item already has the meaning ā€œlist itemā€ so putting paragraphs inside it is… serious ā€œwhat the?ā€ – Which is it, a list item or a paragraph? Part of why I consider it inappropriate to have multiple block-level tags inside a ā€œlist ITEMā€ā€¦ singular.

It’s one of those things that you CAN do – but that’s like I CAN go drive my car off a cliff; doesn’t mean it’s something I SHOULD go do. Just because you CAN do something doesn’t mean you SHOULD.

as the conversation went in a good manner, I would like to give two more example to make even more clear about it:

The following is the example of companies list on a yellow page site.

I will write only html, css should be used to make proper float and everything:


<div>
  <span>3</span>
  <img src="example.png" />
  <h3><a href="#">Company name Ltd</a></h3>
  <p><span>company address 2, 34334 city</span><br />
  Company intro Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed 
  at velit ut ante fermentum hendrerit. Phasellus quis eros ne</p>
</div>
<div>
  <span>4</span>
  <img src="example.png" />
  <h3><a href="#">Company name Ltd</a></h3>
  <p><span>company address 2, 34334 city</span><br />
  Company intro Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed 
  at velit ut ante fermentum hendrerit. Phasellus quis eros ne</p>
</div>
...

I used here divs instead of li. Anyway this is kind of list, companies list so also li would be appropriate, if not mix block and inline? I put address and intro together to <p> and <span> inside it, is that semantically correctly?

Example 2:


<div>
  <p class="from">From</p>
  <p class="subject">Subject</p>
  <p class="date">Date</p>
</div>
<div>
  <img src="" class="profileImg">
  <p><a href="">John Piterson</a></p>
  <h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at velit ut 
  ante fermentum.</h3>
  <p>2011-02-19 16:18:23<br />read</p>
  <input type="checkbox" />
</div>
<div>
  <img src="" class="profileImg">
  <p><a href="">John Piterson</a></p>
  <h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at velit ut 
  ante fermentum.</h3>
  <p>2011-02-19 16:18:23<br />read</p>
  <input type="checkbox" />
</div>
...

I used p tags for From,Subject and Date. Or should I used span instead of p?

There are a number of wrongs with the above, but the main part about Example 2 is that you should use a… table!

Now, Example 1 would be lists also, in my opinion. Semantics is not about what the text stands for (address or intro), but what it is for. You don’t question ā€œdo address and intro mix?ā€, since the browser doesn’t care what you write about, you question like in grammar classes: what this represents: a heading, a paragraph, a phrase element, a tabular data (table), a list etcetera. And use the appropriate element for that bit of your web page.

the problem is that I am not sure in grammar what is ā€œ2011-02 16:18:23ā€ or ā€œFromā€. It is not strict pharagraph or headline, so what is it?

lol

ā€œFromā€ is a column header, ā€œ2011-02 16:18:23ā€ is a cell value. That’s what I’m seeing there.

You know there is more than grammar at play here, right? : )

Let’s start with the basics.

  1. All you have is content. You should be aware of how the content is structured and what every bit of it stands for BEFORE starting the html mark up.

  2. HTML gives you elements: structural elements and content elements. Each with it’s on semantic.

All you have to do (simple, right? :lol:) is to structure and tag your content, using proper elements.

Semantics means putting the equal sign between those two: 1 = 2.

clarifying…

OK I shoudl have corrected all semantics… but I am sleepy

anyway,

what I mean as ā€œyour sentenceā€ was this:
<a href=ā€œ#ā€>First name</a><strong>Message title lorem ipsum</strong><span>12.02.2010</span>
correcting your sentence semantics:
<a href=ā€œ#ā€>First name</a><span class=ā€œboldedā€>Message title lorem ipsum</span><span>12.02.2010</span>

so that means you could see it a a SINGLE complete sentence in which the A and the spans are partial phrases. Anyway…
<p><a href=ā€œ#ā€>First name</a><span class=ā€œboldedā€>Message title lorem ipsum</span><span>12.02.2010</span></p> would then make sense

but since it goes in a list:<li><p><a href=ā€œ#ā€>First name</a><span class=ā€œboldedā€>Message title lorem ipsum</span><span>12.02.2010</span></p><li>
but then u see that the P in that case is redundant

<li><a href=ā€œ#ā€>First name</a><span class=ā€œboldedā€>Message title lorem ipsum</span><span>12.02.2010</span><li>

but if you were going to have ANOTHER sentence/paragraph within the LI then you would need the P around both… see
I hope I have cleard my previous point… as far as grammar is concerned dont thinkof it as a REAL english or any language sentence… thing of iut as teh structure of the sentece…

<a> subject</a> <span> object</span><span>indirect object</span>

Both of those are pretty bad – the first one they’re all numbered, which might be enough to make me backtrack on my previous statements as that STARTS to look like something that should be in a OL. ONe thing I’m certain of is that stuff in the span is NOT part of the sentence/paragraph that follows, so it should NOT be in the paragraph with a BR, if anything it should be in the HEADING tag as it is part of the HEADING.

The latter one though as noonnope pointed out is really just wrong. Column headings with rows that are obvious records means that semantically that is TABULAR DATA, so get that into the SEMANTICALLY CORRECT tags, a TABLE. NONE of the text present are gramattically paragraphs so WHY are you using paragraph tags around them?!? Much less the H3 that frankly, isn’t being used as a section heading so a heading tag is semantically incorrect TOO!


<thead>
	<tr>
		<th>From</th>
		<th>Subject</th>
		<th>Date</th>
		<th class="check"></th>
	</tr>
</thead><tbody>
	<tr>
		<td>
			<img src="" class="profileImg">
			<a href="">John Piterson</a>
		</td><td>
			Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at velit ut ante fermentum.
		</td><td>
			2011-02-19 16:18:23<br />
			read
		</td><td class="check">
			<input type="checkbox" />
		</td>
	</tr><tr>
		<td>
			<img src="" class="profileImg">
			<a href="">John Piterson</a>
		</td><td>
			Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at velit ut ante fermentum.
		</td><td>
			2011-02-19 16:18:23<br />
			read
		</td><td class="check">
			<input type="checkbox" />
		</td>
	</tr>
...

Do not use non-table tags on OBVIOUSLY TABULAR DATA! When you have rows and columns where the columns are all the same type of data as specified by their header, that’s TABULAR data. That’s what THEAD and TH are for, with TBODY specifying the start of your DATA.

deathshadow60 thank you for explanation. I understand now, excepting again about pharagraph. Let’s say it is ok to not use table in this case (I know I should it, but just for example). What would be in this case those pharagraphs if not pharagraph?

If you look even w3.org use p for such thing p tag. If you scroll down the index page to the events, you will see:

Think Mobile First, Then Enhance
by Karl Dubost
Confoo 2011
Montreal, Canada

They use for each line a new pharagraph. by Karl Dubost seems to me as much pharagraph as things I put into pharagraph in my example.

deathshadow60 thank you for explanation. I understand now, excepting again about pharagraph. Let’s say it is ok to not use table in this case (I know I should it, but just for example). What would be in this case those pharagraphs if not pharagraph?

If you look even w3.org use p for such thing p tag. If you scroll down the index page to the events, you will see:

Think Mobile First, Then Enhance
by Karl Dubost
Confoo 2011
Montreal, Canada

They use for each line a new pharagraph. by Karl Dubost seems to me as much pharagraph as things I put into pharagraph in my example.

Even the people writing the website at the W3C often fail to grasp their own rules – though with semantics the poorly written legalese of the specification does NOT help matters any.

My question would be, what makes an incomplete sentence fragment a paragraph or even need an extra block-level container around each and every line… NOTHING. Frankly, there is no reason for those even to have tags around them.

It doesn’t help when you look at the code and immediately realize that whoever wrote the W3C’s home page failed to grasp even the simplest concepts of HTML and CSS… For example:


<ul class="hentry_list">
      <li class="hentry">
         <p class="entry-title">
            <a href="http://www.w3.org/QA/2011/02/do_not_track_at_w3c.html" class="uri url" rel="bookmark">Do Not Track at W3C</a>
         </p>
         <p class="date">
            <abbr title="2011-02-24" class="published">24 February 2011</abbr> by <span class="author vcard">
               <a class="fn url" href="http://log.does-not-exist.info/">Thomas Roessler</a>
            </span>
         </p>
      </li>
      <li class="hentry">
         <p class="entry-title">
            <a href="http://www.w3.org/QA/2011/02/w3c_technologies_for_mobile_we.html" class="uri url" rel="bookmark">W3C Technologies for Mobile Web Applications</a>
         </p>
         <p class="date">
            <abbr title="2011-02-24" class="published">24 February 2011</abbr> by <span class="author vcard">
               <a class="fn url" href="http://www.w3.org/People/Dom/">Dominique Haza&#xEB;l-Massieux</a>
            </span>
         </p>
      </li>

Even if you agree to make that a list (I wouldn’t) it’s got a perfectly good class on the UL what the blue blazes is it WASTING code putting classes on the LI. If every child element is getting the same class, they don’t need classes in the first place!!!

From there you have the microformat nonsense around the date (adding ZERO useful information BTW), a span around the second anchor for no good reason, vague/meaningless classes like ā€œfnā€, pointless classes like ā€œurlā€ (an anchor is a url?!? Who’d have thought?)… The paragraphs around elements that are NOT PARAGRAPHS… The list of ineptitude and/or ignorance goes on and on.

This is apparent in the page failing the litmus test for good HTML coding; it has 29k of markup to deliver 4.7k of plaintext; basically THREE TIMES the size HTML file that should be used for such a simple layout – and that’s AFTER they whitespace strip it with no comments?!?

Or that the layout is broken on large font/120dpi systems as they failed to grasp when to use px, when to use %/em, and that fixed height backgrounds on dynamic content is a miserable /FAIL/ at web development.

… and we’re talking the website of the group that’s supposed to be setting the standards? So much for leading by example!

noonnope and deathshadow60, please give me some examples of sites you coded please, so I will have at least some sites that I can use it for learning a proper coding and to see proper css in action. I really ment it, it is not sarcasm. I like to learn from real cases.

For me, at the moment, it’s pretty impossible to help with that. All the work I do is for Intranet.

I actually had some trouble on a few part-time jobs interviews, because of that, them asking for a portfolio in advance :frowning:

But ds60 has some pretty fine examples on his pages. And so does Paul O’B, Rayzur, to name just a few on SPF.

Well, right now my most recent I can publicly share (I’ve got one client that’s a government agency which doesn’t like me to say I work for them) are my own crappy little project pages:

Home - EWI USB
Home - DEATHSHADOW PASCAL

Both of these use very solid coding techniques which is why the first one ranks #2 behind the official site for the product on most relevant searches… despite having nowhere near the legacy presence or link juice. With one simple marketing push (if I had any reason to put the effort in – like a revenue stream for it) I could easily push them out of the top slot.

The latter one has been mostly an experimental page for wild theme ideas (like the current ugly green retrocomputing one) and testing things like REAL accessibility menus. (hit shift-esc in opera to see what I mean).

… and there are two clients I can list from before I ā€˜retired’ from doing jobs for the public.
Home - Publish or Perish

Simple page, uses a mcSwitchy type script (I call it quickSwitchy since it lets CSS do the real grunt work) to vary the width and number of columns, the CMS is simple enough they’re able to maintain/modify it without handholding (important for the ā€œtrainingā€ page), contact form has transparent fall-through server side so the validation script behavior is near identical when scripting is off, it’s just ā€˜faster’ when scripting is present…

There’s also a client who I did the base template and CMS, (his color choices) though they’ve screwed with it a lot it’s still pretty solid.
http://www.topgamez.net/

In fact, all of those sites use my private from-scratch CMS under the hood.

But to give it some perspective, my biggest client I did BEFORE I learned all these semantics and modern coding techniques – or that ā€œgee ain’t it neatā€ scripted nonsense is more headaches than it’s worth – I’ll give you an example of BAD work by me before I learned all this stuff:

Catalyst Game Lab’s Official Classic Battletech Website

To show that we all start somewhere. That page is BAD, but I wrote it seven or eight years ago. I was talked into the stupid news popups when I should have put my foot down, it relies on tables for nothing across the ENTIRE page, uses WAY too many separate files for things, uses javascript (and a really outdated one) to change the location bar (something that should have been handled server-side), and is chock full of some of the most non-semantic markup out there – Thankfully it has content of value letting all those sins slide; hence it’s top ranking on the search engines for relevant subjects. (something said companies newer efforts using turdpress cannot claim and are unlikely to ever manage – especially with all the endless redirects and URL games they play)

BTW – if your own work from just a year or two ago doesn’t disgust you, you’re in the wrong business :smiley:

Though a common issue many of us face is that by the time the client has maintained a site by themselves for a while you often wish you weren’t associated with them.

One site that would have been REALLY good to point you at would have been CUTCODEDOWN.COM - Minimalist Semantic Markup Development, but that project is on hold indefinitely (hence the placeholder) as the person I was creating that new website with passed away; and without his drive the whole project has stagnated.

Though feel free to look through the directory of rewrites I’ve done for people here and on digital point:
Index of /for_others
Some of that’s just small snippets to answer questions – some of it are total from the ground rewrites of what people were trying to do. A lot of times the best answer to ā€œwhat’s wrong with my siteā€ on a forums is ā€œthrow it out and start overā€ – when it’s a nube I often like to give them a well documented rewrite of one page to give them a head-start and to show all the advantages of doing things with semantics and separation of presentation from content.

… and the WIP tutorials directory (which has some web rot, not really meant for public presentation yet) that was going to build the core of cutcodedown.com
Index of /html_tutorials

and some more recent rewrites of two of those tutorials
Index of /tutorials

I AM planning on launching a new modern site at deathshadow.com that will make use of all the new techniques I’ve put together over the past year (which is how long it’s been since I launched anything new) – this site will be used to promote my new hobby; writing new DOS games that will run on the original IBM PC 5150/5160 (assuming they have at least 128 megs of RAM)… As I switched to doing that out of disgust of dealing with people not caring about doing websites properly or even TRYING to be anything more than sleazy scam artists.

One of the advantages to being officially retired, I can work on whatever the hell I feel like now instead of catering to the whims of people who always made me feel like screaming ā€œIf you think you know so damned much about it, what the blue blazes did you hire me forā€ā€¦

It’s made me a lot more mellow than I used to be. Yes, this is me MELLOW. I used to be much more arrogant and self-important.