Css id used two times [closed] - html

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I heard that css id can be used for only one element in a page But this is true when we play with script but on presentation alone this is not affecting anything.
presentation Here there is no effect we are able to create things simply(created two div with same id->no effect).
presentation with script activity Here we cannot do anything this is what we know as it can be used only one time.
I know without script we are not going to do anything but i just want to share this things and get other web geeks opinion on this things.

I'm not sure what you're asking or telling us.
It's simply bad form and against spec to use an id twice in the same document, so don't do it.

If you think you want to use multiple ID's what you REALLY want to do is use a class instead.

From the CSS selectors spec:
What makes attributes of type ID special is that no two such attributes can have the same value in a conformant document, regardless of the type of the elements that carry them; whatever the document language, an ID typed attribute can be used to uniquely identify its element.
It does not specify what the UA must do when it encounters such a situation, and as most browsers are very lenient what you propose will most likely be styled correctly. But you will have an invalid document.

Related

What is this <lt-mirror> html tag? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
To make the question short, I was playing with the dom, I created a text-area and noticed that an element tagged lt-mirror was generated whenever the user type something. The new element is placed just before the text-area. Couldn't find any documentation about it across the web ?
The lt-mirror tag was generated by an extension called LanguageTool, which target the text-areas and check for writing errors.
Did some research about this and found something! Okay, so the person who wrote this probably did something called custom elements. Rather than having nested, verbose elements for a page feature, you could use a custom element to make it more comprehensive and most importantly reusable!
You can create a custom element made with your classes, own methods, and properties, etc, and use it with the built-in HTML elements.
You can find more info on it here:
https://javascript.info/custom-elements
https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements
https://developers.google.com/web/fundamentals/web-components/customelements
I guess it's some kind of a custom element.

what are draw backs of using custom HTML tags? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
what are most critical draw backs of using custom HTML tags? I need to create custom HTML5 tags and looked it up and found pros and cons list but now I'm looking for a draw back that might lead to a huge failure. can anyone help me with that please.
By definition a custom tag is an HTML element that its properties are defined by programmers as opposed to the user agent. basically, custom elements provide a tool for programmers to build their own DOM elements. Programmers can always use non-standard elements in their documents, with application-specific behavior added after the fact by scripting or similar, such elements have historically been non-conforming and not very functional. creating a custom element, we can inform the parser how to properly construct an element and how elements of that class should react to changes.
having said that, the biggest drawback is that, simply defining an element doesn’t mean that the element inherits all attributes and properties as you intended. for example if you create a tag, that doesn’t mean that your newly created tag is suppose to act like a button.

Should we always specify an ID attribute in HTML? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
From https://www.w3schools.com/tags/att_global_id.asp:
In HTML5, the id attribute can be used on any HTML element (it will validate on any HTML element. However, it is not necessarily useful).
I'm making a browser-based application for internal use, which in one of the pages there is no CSS or JavaScript referring to any element of the page - just tables.
Should I still specify the id attribute for the elements though there is no (not yet) need to use it? Or it is just best practice to put id'entifiers for future use?
Only put required elements or attributes in HTML.
You do not need to put ID attribute if it is not required, and you can always add ID attribute whenever required.
Keeping only required elements in html will make it easy to read, clean, low on size and hence improves performance and speed.
IDs are useful if you want to perform end-to-end testing with a framework like Protractor since it is very easy to select the particular element you want. This is not necessary, however, because of CSS attribute selectors. You can select on parts of the CSS class in the DOM, even without an ID being present.
Does the ID make it easier? Sure, but is it required for displaying a page? No.
No need to add IDs if you're not going to use them. It will just add extra bytes to your website to load. I don't see why would you think you need them, the quoted text you added to your question doesn't say you should use them, it just says they CAN be used on any element.
No, it is not necessary. It is required only when you have to access any form control uniquely on a web page.

A confusion i have about HTML "classes" [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Hello and thanks in advance. In HTML I know that a "class" will not really have an effect unless it is related to something in CSS or JS. At the same time, I find some "classes" that do affect the structure of a documents even without an associated CSS, such as "class="col-md-12" for example. Can someone explain why some classes work independent of CSS? And how to know them.
class="col-md-12" still requires CSS. That is a common class for a framework such as BootStrap. On its own without JavaScript or CSS, a class does nothing besides tell another programmer what an element is for.
The idea of classes ("class=''") and identifiers ("id=''") is part of DOM manipulation. You can put in classes and id's in each of the tags as you desire. Normally, the rule is an independent id for each tag, and a class for each GROUP of identical tags.
To make use of classes, you are required to use CSS, be it at the top of the page, or linked to another page. If you have your CSS at the top of the page, you do not need another CSS page, however most designers will frown from that.
See here for a more in-depth explanation: https://css-tricks.com/the-difference-between-id-and-class/

What is a semantically correct HTML element for a "statusbar"? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am writing a simple webapp and I need a status bar. Something that updates often to reflect what JavaScript is doing. It will only contain text, short complete sentences, but in the future it might have small informational images. Like, "An error occured" or "Please wait, loading..." or "Player 2 has disconnected". Now, I know how to make one, but my question is:
What is the most semantically correct HTML element to use for this?
Or will I have to resort to a <div> or <span>? If so, which one? I generally avoid those because they seem like a last resort.
Also, the statusbar may be anywhere on the page. Don't base your answer on its location on the page, that's not what semantics is about.
Please support your answer with some sort of official resource (w3, anything) if you can.
Being unable to find any source of information, I'll answer all by myself and defend my position. My answer is: it depends. The direct answer to your question is that there's no element specific for the status.
However, when this happen the solution normally chosen is to use a generic element as <div> or <span> and assign it some semantics. This can be achieved with class and id, as you are well aware. We cannot expect html to be perfectly semantic and cover every case possible. They are trying their best to cover the most common uses.
A very similar case is the <nav>. It was really common to see <div class = "nav"> or similar code in old html. w3 realized of this and changed it to make it more semantic. Maybe/hopefully they'll do the same for all those class = "status" for a <status>, it just hasn't happened yet.
For solving your problem right now: I'd recommend using a <p class = "status"> actually if your code is going to contain only a paragraph, as it seems. It's slightly more semantic than <div> and <span>.