2

I've recently started learning Angular. One thing I noticed in sites using Angular, is that the output HTML includes attributes such as ng-version, _nghost-c0 and similar versions, and some other ones beginning with ng-. I also notice some tag names like <landingpagecarousel>. None of these are valid according to the w3c specifications (custom attributes must start off with data- and custom tagnames must include a dash).

Is this simply the result of the developers not caring much about the validity of their document or is it actually not possible to output a valid HTML document using Angular?

When I built a little tic-tac-toe game myself as a first project, I figured the tagnames are completely in the hands of the developer (are they?) however I felt like most of the Angular-related attributes are just part of how the framework works, and I have no control over them. Is this the case?

So, is it possible to create a site with Angular (i.e. not one that's empty just for the sake of being valid) that outputs a valid HTML document?

An example of one of the sites I looked at: https://developer.db.com/

vrugtehagel
  • 1,009
  • 1
  • 9
  • 20
  • 1
    If it wasn't valid angular wouldn't work – Liam Aug 07 '20 at 08:26
  • 1
    That's not true. A lot of websites don't comply to the HTML specs and they still work. However, I'll update the question with an example site to further support this. – vrugtehagel Aug 07 '20 at 08:28
  • "A lot of web sites don't comply to the HTML specs"? Like? If you don't comply to the specs then your site won't work. Also which specs? [There are multiple](https://www.w3.org/TR/?tag=html) – Liam Aug 07 '20 at 08:30
  • 1
    The [w3c specs](https://html.spec.whatwg.org/multipage/) define exactly what constitutes as a valid HTML document and what doesn't. Like all languages, they have a certain set of rules that decide whether or not the code is valid. HTML is not just XML. – vrugtehagel Aug 07 '20 at 08:33
  • 2
    Custom elements are defined in the w3c specs https://www.w3.org/TR/dom41/#interface-element. I don't see anything invalid in the examples you've given – Alex Aug 07 '20 at 08:36
  • Well there's [HTML 5](https://www.w3.org/TR/html52/grouping-content.html) and [HTML 4.01](https://www.w3.org/TR/html401/struct/text.html), not to mention the living documents and the RFSs. Where exactly have you gotten the information that "None of these are valid according to the w3c specifications". Where in the specs does it state this and which specs are you referencing? – Liam Aug 07 '20 at 08:36
  • Its a bit like .net code has standards for the naming of properties and methods, (like dont include a type such as Obj in the name). These are part of the standard, however, there are multiple examples of .net functions and methods breaches these standards themselves. Another example. in the UK the standard is to drive on the left. Doesnt mean the car stops working if you drive on the right. – JohnnyJP Aug 07 '20 at 10:01

0 Answers0