Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "semantically correct" mean?

I have seen it a lot in css talk. What does semantically correct mean?

like image 222
johnny Avatar asked Aug 18 '09 15:08

johnny


People also ask

What is a semantically correct sentence?

in order for the sentence to also be semantically correct, it needs to be a verb that describes movement from one place to another. so if you say "I go to the store," that's both syntactically and semantically correct.

What is semantically wrong?

Writing invalid program logic that produces incorrect results when the instructions are executed. The syntax of the source code may be valid, but the algorithm being employed is not.

What is semantically correct HTML?

Semantic HTML is the correct use of HTML to reinforce the meaning of content on a web page, rather than merely define its appearance. Semantically correct HTML helps search engines, screen readers, and other user devices determine the significance and context of web content.

What is a sentence that is syntactically correct but semantically incorrect?

Here is a sentence that is syntactically correct, but semantically incorrect: The green apple ate a juicy bug. The syntax is correct. That means the sentence is well-formed and structured properly. It contains articles in the appropriate places, the adjectives precede the nouns, and the verb is correctly conjugated.

What does semantically correct mean in HTML?

Semantics basically means "The study of meaning". Usually when people are talking about code being semantically correct, they're referring to the code that accurately describes something. In (x)HTML, there are certain tags that give meaning to the content they contain. For example: An H1 tag describes the data it contains as a level-1 heading.

What does it mean for a sentence to be grammatically correct?

That means the sentence is well-formed and structured properly. It contains articles in the appropriate places, the adjectives precede the nouns, and the verb is correctly conjugated. The first letter is capitalized and the terminal punctuation mark is in the appropriate place. The sentence is not semantically correct, though.

What is the meaning of semantically in English?

Meaning of semantically in English 1 The first verbs to be acquired by the learner will be semantically general. 2 Our healthcare system will become increasingly digitized and semantically organized. 3 The semantically related words included a variety of semantic relations. More ...


2 Answers

Labeling correctly

It means that you're calling something what it actually is. The classic example is that if something is a table, it should contain rows and columns of data. To use that for layout is semantically incorrect - you're saying "this is a table" when it's not.

Another example: a list (<ul> or <ol>) should generally be used to group similar items (<li>). You could use a div for the group and a <span> for each item, and style each span to be on a separate line with a bullet point, and it might look the way you want. But "this is a list" conveys more information.

Fits the ideal behind HTML

HTML stands for "HyperText Markup Language"; its purpose is to mark up, or label, your content. The more accurately you mark it up, the better. New elements are being introduced in HTML5 to more accurately label common web page parts, such as headers and footers.

Makes it more useful

All of this semantic labeling helps machines parse your content, which helps users. For instance:

  • Knowing what your elements are lets browsers use sensible defaults for how they should look and behave. This means you have less customization work to do and are more likely to get consistent results in different browsers.
  • Browsers can correctly apply your CSS (Cascading Style Sheets), describing how each type of content should look. You can offer alternative styles, or users can use their own; as long as you've labeled your elements semantically, rules like "I want headlines to be huge" will be usable.
  • Screen readers for the blind can help them fill out a form more easily if the logical sections are broken into fieldsets with one legend for each one. A blind user can hear the legend text and decide, "oh, I can skip this section," just as a sighted user might do by reading it.
  • Mobile phones can switch to a numeric keyboard when they see a form input of type="tel" (for telephone numbers).
like image 63
Nathan Long Avatar answered Oct 02 '22 19:10

Nathan Long


Semantics basically means "The study of meaning".

Usually when people are talking about code being semantically correct, they're referring to the code that accurately describes something.

In (x)HTML, there are certain tags that give meaning to the content they contain. For example:

An H1 tag describes the data it contains as a level-1 heading. An H2 tag describes the data it contains as a level-2 heading. The implied meaning behind this is that each H2 under an H1 is in some way related (i.e. heading and subheading).

When you code in a semantic way, you basically give meaning to the data you're describing.

Consider the following 2 samples of semantic VS non-semantic:

<h1>Heading</h1> <h2>Subheading</h2> 

VS a non-semantic equivalent:

<p><strong>Heading</strong></p> <p><em>Subheading</em></p> 

Sometimes you might hear people in a debate saying "You're just talking semantics now" and this usually refers to the act of saying the same meaning as the other person but using different words.

like image 20
Jamie Dixon Avatar answered Oct 02 '22 18:10

Jamie Dixon