HTML/CSS How can I implement a website using HTML and CSS without functionality?

Click For Summary
To implement a website using HTML and CSS without functionality, one can either use a web design editor or write directly in text files. Key components include using the <style> tag in the <head> section for CSS and structuring content within the <body> section using HTML elements. Issues discussed include the proper use of attributes like rowspan in tables and the importance of setting image dimensions to control layout. The conversation also highlights the use of padding for spacing and the necessity of linking to valid image sources. Overall, the thread emphasizes foundational HTML and CSS techniques for creating a static website layout.
  • #31
Klaas van Aarsen said:
What do you mean? o_O
I get:

what_I_get.png


But at the desired result we have more space before the price:

how_it_should_be.png


For my result I wrote: https://www.w3schools.com/code/tryit.asp?filename=GOFDGKW0LQ9Z

Do we have to add an empty row before the price or how do we get the desired result? :unsure:
 
Technology news on Phys.org
  • #32
evinda said:
For my result I wrote: https://www.w3schools.com/code/tryit.asp?filename=GOFDGKW0LQ9Z

Do we have to add an empty row before the price or how do we get the desired result?
I see you've split the text in the middle over multiple rows.
But I don't think that is desired, since "CPU:" belongs to what comes after.
So I think the text in the middle should go into a single cell so that its get wrapped however it will fit.
Consequently the lines of this text will get a little closer together.
We should also add a space after interpunction so that the wrapping happens more naturally.
We might then leave the price as is.

See https://www.w3schools.com/code/tryit.asp?filename=GOFFXLWHR2ZP
1615406261139.png
Alternatively we can put a<br/> after the text in the middle.
Or we can use CSS to add padding such that we get more space between the text and the price.
Or we can use CSS to specify a height for the row that the price is in. 🤔
 
Last edited:
  • #33
Klaas van Aarsen said:
I see you've split the text in the middle over multiple rows.
But I don't think that is desired, since "CPU:" belongs to what comes after.
So I think the text in the middle should go into a single cell so that its get wrapped however it will fit.
Consequently the lines of this text will get a little closer together.
We should also add a space after interpunction so that the wrapping happens more naturally.
We might then leave the price as is.

See https://www.w3schools.com/code/tryit.asp?filename=GOFFXLWHR2ZP
https://www.physicsforums.com/attachments/11015Alternatively we can put a<br/> after the text in the middle.
Or we can use CSS to add padding such that we get more space between the text and the price.
Or we can use CSS to specify a height for the row that the price is in. 🤔

Now it works! (Nod)
Can you explain to me each parameter of:

Code:
<input type="checkbox" checked="checked" value="Text1">Text1<br/>
<input type="radio" name="Text" value="Text2">Text2<br/>
<input type="text" id="uname" name="name" placeholder="From" size="7">

What is the purpose of each parameter? 🧐
 
Last edited:
  • #34
evinda said:
Code:
<input type="checkbox" checked="checked" value="Text1">Text1<br/>
<input type="radio" name="Text" value="Text2">Text2<br/>
What is the purpose of each parameter?

The type is how it is shown in the browser and how it behaves when we click it.
checked is to set the initial state of the checkbox to either checked or unchecked. Often this will be omitted from the html code, but will instead be manipulated by javascript code.
At this time - for the html and css layout - we don't really need the other parameters and we can just omit them. 🧐

value is a value that javascript code can use to recognize what it needs to do.
name is an identification that javascript code can use to refer to the element and change for instance the checked status.
The Text1 that is outside the <input> tag is usually equivalent to the value, but it is what it shown to the user while the value is what is used by the javascript code. 🧐

We might have for instance:
Code:
Device types (check what you want to filter on):
<input type="checkbox" checked="checked" value="showAndroidDevices">Android<br/>

Operation System (select the operating system for the device):
<input type="radio" name="selectAndroidOperatingSystem" value="1">Android<br/>
🤔
 
Last edited:
  • #35
At
Code:
<input type="text" id="uname" name="name" placeholder="From" size="7">

For the size part I have to try different sizes (7,8,9,..) till my result is the same as the desired result. Is that right? :unsure:
I mean for:
1615474905901.png
 
  • #36
evinda said:
At
Code:
<input type="text" id="uname" name="name" placeholder="From" size="7">

For the size part I have to try different sizes (7,8,9,..) till my result is the same as the desired result. Is that right? :unsure:
I mean for:
https://www.physicsforums.com/attachments/11016
The html should be without size.
We have css for that.
In the css we can specify the font-size if the default is not good enough.

For the record, the result does not have to be exactly the same as the screenshot. 🤔
 
Last edited:
  • #37
Did you already get the submit button with the στρογγυλεμένες γωνίες? (Wondering)
 
  • #38
Klaas van Aarsen said:
Did you already get the submit button with the στρογγυλεμένες γωνίες? (Wondering)

Yes, I have done this! (Nod)

Now I try to make all these buttons to have a function. This part is done. But what I haven't achieved yet is that all these filters are combined. I have achieved that if I select a mobile phone only this picture is shown, if I select the screen size only the respective picture (or nothing at all) is shown and if I select a system only a picture of the mobile that has this system is shown. For this I used Javascript functions, I wrote each of these properties in different function. Is it possible to combine all these filters? I tried to write one function for all properties, but then no filter works. :unsure:
 
  • #39
We can have a single function for the fliter button at the bottom that first collects the status of all the options, and then shows the corresponding pictures. 🤔
 
  • #40
Klaas van Aarsen said:
We can have a single function for the fliter button at the bottom that first collects the status of all the options, and then shows the corresponding pictures. 🤔

You mean to write in the function all possible combinations? I mean if we select from the first filter option1 from second filter option1 and from the third filter option1 then show this piicture, if we select from the first filter option1 from second filter option1 and from the third filter option3 then show this piicture, etc? 🧐
 
  • #41
evinda said:
You mean to write in the function all possible combinations? I mean if we select from the first filter option1 from second filter option1 and from the third filter option1 then show this piicture, if we select from the first filter option1 from second filter option1 and from the third filter option3 then show this piicture, etc?
I'd say the other way around.
We show the first picture if it matches filter option 1, filter option 2, and filter option 3. And then the same for the 2nd picture and/or any others if we have them. 🤔
 
  • #42
Klaas van Aarsen said:
I'd say the other way around.
We show the first picture if it matches filter option 1, filter option 2, and filter option 3. And then the same for the 2nd picture and/or any others if we have them. 🤔

So we write in javascript
Code:
Pic1.style.display = "block"
and we write all cases that should satisfy inside swich-statements? :unsure:
 
  • #43
evinda said:
So we write in javascript
Code:
Pic1.style.display = "block"
and we write all cases that should satisfy inside swich-statements?

I'd imagine we'd write something like:
Code:
if (document.getElementById('Apple').checked && document.getElementById('iOS').checked) {
  picAppleiPhone7.style.display = 'block'
} else {
  picAppleiPhone7.style.display = 'none'
}
🤔
 
  • #44
Klaas van Aarsen said:
I'd imagine we'd write something like:
Code:
if (document.getElementById('Apple').checked && document.getElementById('iOS').checked) {
  picAppleiPhone7.style.display = 'block'
} else {
  picAppleiPhone7.style.display = 'none'
}
🤔
So do we have to write this for each filter seperately and for each combination of filters?

Code:
if (document.getElementById('Apple').checked) {
  picAppleiPhone7.style.display = 'block'
} else {
  picAppleiPhone7.style.display = 'none'
} 
if (document.getElementById('Apple').checked && document.getElementById('iOS').checked) {
  picAppleiPhone7.style.display = 'block'
} else {
  picAppleiPhone7.style.display = 'none'
} 
if (document.getElementById('Apple').checked && document.getElementById(' inches ').checked) {
  picAppleiPhone7.style.display = 'block'
} else {
  picAppleiPhone7.style.display = 'none'
} 
if (document.getElementById('Apple').checked && document.getElementById('iOS').checked && document.getElementById(' inches ').checked) {
  picAppleiPhone7.style.display = 'block'
} else {
  picAppleiPhone7.style.display = 'none'
}

And so on? 🧐
 
  • #45
That won't work...
We have to combine them. Otherwise the last filter will overrule the others. 🤔
 
  • #46
Klaas van Aarsen said:
That won't work...
We have to combine them. Otherwise the last filter will overrule the others. 🤔

By combining them you mean to write all the possible combinations in one if'statement? :unsure:
 
  • #47
evinda said:
By combining them you mean to write all the possible combinations in one if'statement?

Yes. (Nod)
 
  • #48
We can introduce helper functions to do it so that we end up with for instance:
Code:
showProductIf('IPhone7', brandMatches('Apple') && screenSizeMatches(6.1) && operatingSystemMatches('iOS'))
🤔
 
  • #49
Klaas van Aarsen said:
We can introduce helper functions to do it so that we end up with for instance:
Code:
showProductIf('IPhone7', brandMatches('Apple') && screenSizeMatches(6.1) && operatingSystemMatches('iOS'))
🤔

Do we have to define a function that shows a product if the specific properties are satisfied? :unsure:
 
  • #50
evinda said:
Do we have to define a function that shows a product if the specific properties are satisfied?
Nope. We don't have to.
It's just a way to make it more readable and manageable. 🤔
 
  • #51
Klaas van Aarsen said:
Yes. (Nod)

I wrote now an if-statement with all possible combinations, which are 27 :oops: When I tried examples to check if the result is correct then I noticed that the casesI have written at the end are not computed correctly. Can that be because I have written so many "else if" ? Or must there be an error at the code? 🧐
 
  • #52
evinda said:
I wrote now an if-statement with all possible combinations, which are 27 When I tried examples to check if the result is correct then I noticed that the casesI have written at the end are not computed correctly. Can that be because I have written so many "else if" ? Or must there be an error at the code?

I don't think we can really write too many "else if"'s for the code to handle.
So there must be in an error in the code. 🧐

Btw, we have 2 checkboxes, 3 choices for the screen size, and 2 options for the operating system.
Doesn't that mean we should have 2 x 2 x 3 x 2 = 24 combinations? 🤔
 
Last edited:
  • #53
Klaas van Aarsen said:
I don't think we can really write too many "else if"'s for the code to handle.
So there must be in an error in the code. 🧐

Btw, we have 2 checkboxes, 3 choices for the screen size, and 2 options for the operating system.
Doesn't that mean we should have 2 x 2 x 3 x 3 = 36 combinations? 🤔

I wrote it again. I wrote each of the 36 combinations analytically. Now it doesn't work at all. 🧐
I don't know what I am doing wrong, I don't see any mistake at the code. Here is what I have written: https://pastebin.com/mpw6PDYw :unsure:
 
  • #54
evinda said:
I wrote it again. I wrote each of the 36 combinations analytically. Now it doesn't work at all.
I don't know what I am doing wrong, I don't see any mistake at the code. Here is what I have written: https://pastebin.com/mpw6PDYw

We can debug and step through the code to figure it out.
Right click on the web page and select Inspect Element.
Find where your javascript source code is and set a breakpoint.
Execute the scenario that fails, which should then stop in the debugger from where you can inspect all expressions, and step through the if statements to see if we land where we're supposed to be. 🤔
 
  • #55
Klaas van Aarsen said:
We can debug and step through the code to figure it out.
Right click on the web page and select Inspect Element.
Find where your javascript source code is and set a breakpoint.
Execute the scenario that fails, which should then stop in the debugger from where you can inspect all expressions, and step through the if statements to see if we land where we're supposed to be. 🤔

I found the typo I had, now every case of the if-statement works. Now an oher problem appears. :oops: I cannot click the first checkbox ("Apple"), only if I click first at the second one ("Samsung") and then I can click on "Apple"or in general if I click first any filter then I can click on "Apple". What could be the reason? 🧐It is not related to the if-stetements, is it? :unsure:
 
  • #56
evinda said:
I cannot click the first checkbox ("Apple")
What do you mean exactly? (Wondering)
 
  • #57
Klaas van Aarsen said:
What do you mean exactly? (Wondering)

I click the checkbox of "Apple" but it is not getting marked. If I click first any other filter and then I try to click the checkbox of "Apple" then it gets marked. 🧐
 
  • #58
evinda said:
I click the checkbox of "Apple" but it is not getting marked. If I click first any other filter and then I try to click the checkbox of "Apple" then it gets marked.
That sounds strange. It suggests that it was disabled somehow but is enabled later on. It is possible from html, css, and javascript. But it seems unlikely you'd have done that.
Do you have the page somewhere? 🤔
 
  • #59
Klaas van Aarsen said:
That sounds strange. It suggests that it was disabled somehow but is enabled later on. It is possible from html, css, and javascript. But it seems unlikely you'd have done that.
Do you have the page somewhere? 🤔

I found my mistake. Now it works! (Nod)
As for the Textboxes at the size of the screen do we have to include them in the if-statements? 🧐
 
  • #60
evinda said:
As for the Textboxes at the size of the screen do we have to include them in the if-statements?
I believe they are intended as a 3rd option yes. 🤔
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K