Hi RNT team. I am using code adapted from your “Build an All-in-One ESP32 Weather Station Shield” to just display 3 parameters from my different sensors (SHT45 and BMP390)and it is working nicely. One change I made was to store index.html in LittleFS in flash memory instead of on an SD card but when I just open index.html directly in my browser all of the items in the table are centre-aligned but when I run the sketch and open the WiFiServer URL in my browser, all of the items in the readings rows are left-justified while the headings row remains centre-aligned. What is the source of that difference? I’m assuming it must be altered by the sketch somehow since the index.html file is the same. I’d like to fix it so that the heading row and data rows are the same. Can you help me? Images illustrating this issue are here: https://imgur.com/a/512Qgxk
Hi.
When you access the web page on your browser, open the console: CTRL+SHIFT + J
Click on the Elements tab.
Now, you can see the HTML file the browser is loading and compare it with the original one to see if any changes were made during the process.
I hope this helps.
Let me know if you need further help.
Regards,
Sara
Thanks for that tip Sara. I found through the elements tab that in the sketch URL version <table> section that the test-alignment was not ‘inherited from body’ ie it is crossed out but I don’t know why this is handled differently from when just opening the html file directly. I added a ‘test-align: centre’ statement into the table section of the <style> block immediately below the body section which also has that statement and this has corrected the problem. All of the labels and readings in the table are now centre-aligned. It would be good to know why it is not inherited.I have attached a couple of images showing this. https://imgur.com/a/5ZP0oA8
Hi.
That’s a very strange issue.
And unfortunately, it’s hard to understand what might be causing it without further information.
Can you share your files?
Regards,
Sara
Ok.
Here are the index.html and my sensor sketch adapted from your code to use LittleFS instead of an SD card and to read from my sensors:
https://drive.google.com/file/d/1KvKKMsyat81pbh8CltynGPS2loLcmVmN/view?usp=sharing
Index.html is unchanged except for the addition of the text-align statement in the table section to correct the left alignment of the readings rows to be displayed centre-aligned.
Hi again.
I didn’t get the index.html file.
I was asking for the one that wasn’t working to try to understand why it didn’t inherit the style.
It is has probably something to do with escape characters or something like that.
Regards,
Sara
Hi Sarah. The index.html file was there. Just close the first file displayed with X at top left and then both files are listed. However, here is another link with only index.html in the folder. This is the version (your original) that doesn’t work properly when invoked from the sketch although I have added comments in lines 50-53 about the addition I made to correct the problem but the correction line itself is also commented out here.
https://drive.google.com/drive/folders/1x3XEb_dL6dq-lZt8Rz3w0iQf1LIO33hi?usp=sharing
Hi Sara, I think I have found the answer … my further investigations suggest that the text-align property specified in the body is actually inherited by the table element, but the alignment for content inside table cells (td) and header cells (th) is then overriden by the browser’s default stylesheet and left-aligned. This is avoided by setting the text alignment again in the table section or more directly in the table cell sections eg th, td.
Furthermore, apparently a different ‘engine’ is used to display html files viewed directly in a browser than within an application like a sketch ?