I can't see anything necessarily wrong in terms of most browsers but it isn't strictly compliant with the HTML standards.

To be strict HTML, your html files should be including *html* and *body* tags as a minimum.

The *html* tag starts and end the html file - in theory browsers are entitled to ignore content sent to it that doesn't start with *html* tags;

The *body* tag is used to wrap the content of the data which needs to be displayed by the browser.

So in theory - a better results.html would be

   <html>
   <body>
   <h1>{{ question.question_text }}</h1>

   <ul>
   {% for choice in question.choice_set.all %}
         <li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{
   choice.votes|pluralize }}</li>
   {% endfor %}
   </ul>

   <a href="{% url 'polls:detail' question.id %}">vote again?</a>
   </body>
   </html>

At the end of the day though - it really does depend on what correct means to you.

1. Do you want to make sure that your pages are closer to strict HTML - which means that in complex pages, the browser will stand a better chance of displaying what you want

or

2. Do you simply want to ensure that the browser you use displays what you expect - if so - strict HTML isn't necessary; so long as it works for you.


On 06/06/18 18:01, Avitab Ayan Sarmah wrote:
results.html:

<h1>{{ question.question_text }}</h1>

<ul>
{% for choice in question.choice_set.all %}
  <li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{
choice.votes|pluralize }}</li>
{% endfor %}
</ul>

<a href="{% url 'polls:detail' question.id %}">vote again?</a>


detail.html:

<h1>{{ question.question_text }}</h1>

{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}

<form action="{% url 'polls:vote' question.id %}" method="post">
{% csrf_token %}
{% for choice in question.choice_set.all %}
  <input type="radio" name="choice" id="choice{{ forloop.counter }}"
value="{{ choice.id }}" />
  <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}
</label><br />
{% endfor %}
<input type="submit" value="vote" />
</form>

--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6b6eb6ac-7152-474e-88eb-2da9eb473d3f%40googlegroups.com <https://groups.google.com/d/msgid/django-users/6b6eb6ac-7152-474e-88eb-2da9eb473d3f%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--
--
Anthony Flury
email : *[email protected]*
Twitter : *@TonyFlury <https://twitter.com/TonyFlury/>*

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2c13b6c5-1ed5-9758-694c-6b880a63103b%40btinternet.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to