I have a very specific question and I hope thats okay when asking it here.
What of the following is the correct usage:
1)
<div id="more">
<div class="box">
<h4>Links</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</div>
<div class="box">
<h4>Partner</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</div>
<div class="box last">
<h4>More</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</div>
</div><!-- #more END -->
2)
<section id="more">
<div class="box">
<h4>Links</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</div>
<div class="box">
<h4>Partner</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</div>
<div class="box last">
<h4>More</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</div>
</section><!-- #more END -->
3)
<section id="more">
<section class="box">
<h4>Links</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</section>
<section class="box">
<h4>Partner</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</section>
<section class="box last">
<h4>More</h4>
<ul>
<li>List 2</li>
<li>List 2</li>
<li>List 2</li>
</ul>
</section>
</section><!-- #more END -->
Note: the code snippet is placed at the bottom of the site and contains links to partner sites, links to other pages and also insite links linking to another category/page.
If you think none of the above examples is correct, could you maybe post what you think is the best solution here?
And in case 3) is best: Than i should also change h4 to h1 and put them into header ?
None of the above.
Section is defined: "For a section in a document. Such as chapters, headers, footers, or any other sections of the document". Many HTML5 elements, such as section, do not offer new functionality, but instead document semantics (as you have tagged:). Section and div may seem a like; section is actually a div, which in itself contains meta information.
There are 3 general rules of thumb for section:
-Don’t use it just as hook for styling or scripting; that’s a div
-Don’t use it if article, aside or nav is more appropriate
-Don’t use it unless there is naturally a heading at the start of the section
So it really depends on your document's structure. In the HTML, "more" contains a section of hyperlinks. You should pick 2) and change the section-element to nav-element.
http://www.whatwg.org/specs/web-apps/current-work/multipage/sections.html#the-nav-element
I think that 3 is probably the best of the things versions you've listed, though you might want to give the specification a once over, and see how the described usage matches up with what you're doing. One thing I will add is that, unless it's part of a larger grouping of content, you might want to consider using an <aside> tag for wrapping the links, as it's content set aside from the rest of the page. If it's part of a sidebar or footer, however, I'd think the <section> tag would work fine.
As for the issue of <h4> vs <h1>, I'm not 100% sure, but it probably wouldn't hurt. The W3C suggests using tags hierarchically, so I'd say that, unless you've got the link section inside another section that's using an <h1>, then it should be the right thing to do.
Related
I'm trying to have the heading to the left of the list item.
I don't want to nest an ordered list inside of an unordered because I need the list items to be continuous between headings.
This is what I have been using, but I don't like that the heading is indented right, despite not being included in the list item.
Tried using "text-indent:-2em" on the heading but that didn't work.
I even tried creating a separate div and putting the negative text indent there, but that didn't work either.
<ol reversed>
<h3>year</h3>
<li>item</li>
<li>item</li>
<h3>year</h3>
<li>item</li>
</ol>
Tried a few websites:
https://www.htmlgoodies.com/tutorials/getting_started/article.php/3479461
So, I think you are on the right path with the -2em to reverse the indent, but it needs to be placed on "margin-left" instead of "text-indent", and either create a class to call it each time you want to use it:
in CSS:
.unindent{
margin-left: -2em;
}
HTML:
<ol reversed>
<h3 class="unindent">year</h3>
<li >item 1</li>
<li>item 2</li>
<h3 class="unindent">year</h3>
<li>item 3</li>
</ol>
or individually add it to the lines you want "un-indented":
<ol reversed>
<h3 style="margin-left: -2em" >year</h3>
<li >item 1</li>
<li>item 2</li>
<h3 style="margin-left: -2em" >year</h3>
<li>item 3</li>
</ol>
There may be other ways, but that's the simplest way I could think of. Good luck!
I'm brushing up on my CSS skills by going through these challenges, and I'm having trouble with the very first one (see image below).
strong text
I can center the text, but the bullets aren't getting centered with it. See JSFiddle
li {
text-align:center;
}
<ul>
<li>List Number 1</li>
<li>List Number 2</li>
<li>List Number 3</li>
<li>List Number 4</li>
<li>List Number 5</li>
</ul>
The easiest way might be setting list style position to inside.
li {
list-style-position: inside;
text-align: center;
}
<ul>
<li>List Number 1</li>
<li>List 2</li>
<li>List Number 3</li>
<li>List 4</li>
<li>List Number 5</li>
</ul>
Add this code in your css its work.
li {
text-align:center;
list-style-type:none;
}
li:before{
content:'\2022';
margin-right:5px;
}
Here is Demo : http://jsfiddle.net/gyQ2W/1/
Use :before pseudo-element. As content in it you can put images, HTML caracters, etc... Updated your fiddle
https://jsfiddle.net/shbfsoq6/2/
I have written a menu for an Italian restaurant. This menu consists of an unordered list where each li element has a class named "headline". Each of these li elements contains a headline and another ul inside with li-s as dishes.
It looks like this:
<ul>
<li class="headline">
<h3>Kind of dishes</h3>
<ul>
<li>Dish 1</li>
<li>Dish 2</li>
<li>Dish 3</li>
</ul>
</li>
<li class="headline">
<h3>Another kind of dishes</h3>
<ul>
<li>Dish 1</li>
<li>Dish 2</li>
<li>Dish 3</li>
</ul>
</li>
</ul>
I am trying to make a printable version of the menu and have no clue why either "page-break-after" nor "page-break-before" work on ".headline" in CSS.
I tried different display values like "block", "inline-block", or "table-row", because reading certain forums suggested it. I also tried different position values ("absolute","relative","static")...
I also tried to wrap the "headline" li-s with div elements and use page-break on the div elements:
<ul>
<div>
<li class="headline">
<h3>Kind of dishes</h3>
<ul>
<li>Dish 1</li>
<li>Dish 2</li>
<li>Dish 3</li>
</ul>
</li>
</div>
<div>
<li class="headline">
<h3>Another kind of dishes</h3>
<ul>
<li>Dish 1</li>
<li>Dish 2</li>
<li>Dish 3</li>
</ul>
</li>
</div>
</ul>
I start to believe that my only option is to re-think the unordered list concept or deliver a pdf-file on print-demand...
I think I would have chose the second method, because I use the li-s to toggle the ul-s in the mobile version.
Is there a fundamental error I do not see yet, or is it simply not possible to control where page breaks are done in unordered lists?
Edit:
I tried different suggenstions of the "possible duplicate thread" and all what it does (I don't know if I am right there and can explain it properly) is that it tries to make page-breaks...
It generates space between the "headline" li-s containing the ul-s... Unfortunately the blank spaces appear in the middle of the pages (print preview and saved pdf) and have a certain height... so it doesn't really push the "headline" li-s on the next page... just slightly down wherever a "headline"li ends
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
Add break-inside: avoid; to ul
I had the same problem adding page-break-after: always to the li. It was fixed by adding a div inside with page-break-after: always followed by an empty div. It works on both Edge and IE11 as well as on Chrome (not yet tested on Firefox).
Amending your example, it should look like the following:
<ul>
<li class="headline">
<h3>Kind of dishes</h3>
<ul>
<li>Dish 1</li>
<li>Dish 2</li>
<li>Dish 3</li>
</ul>
<div style="page-break-after: always"></div>
<div></div>
</li>
<li class="headline">
<h3>Another kind of dishes</h3>
<ul>
<li>Dish 1</li>
<li>Dish 2</li>
<li>Dish 3</li>
</ul>
<div style="page-break-after: always"></div>
<div></div>
</li>
</ul>
Note: Do not repeat the page-break-after in your headline class.
I'm trying to make it so when I click on the href "+ links", my list of links updates to my other list of links.
Is it possible to do this using only html and css? I am looking for documentation on this but I haven't find anything, so I guess I'm looking for a little help.
<footer id="footer-container">
<section id="footer1">
<ul>
<h1>Links</h1>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li> + links </li>
</ul>
<ul>
<li>Link 5</li>
<li>Link 6</li>
<li>Link 7</li>
<li>Link 8</li>
<li>+ links</li>
</ul>
</section>
</footer>
Simple answer: Not Possible.
CSS & HTML cannot change state via clicks. You can achieve changing which list is shown when the user hovers over something, but you cannot do this when a user clicks something.
EDIT: To respond to your comment about jQuery:
$('#myID').click(function{
Put your changes here. The above line will trigger when a user clicks on an element with the id of myID.
You could accomplish the menu change by hiding and showing:
$('ul#firstList').hide();
$('ul#secondList').show();
You'll need to use an if/else statement to see which list is currently visible though.
});
I would like to have the list items display horizontally and I want to have a line break (like <br />) within the item. What is the easiest way to do it?
I'd say that what you really want is an inline block:
li{
display: inline-block;
}
I'm not entirely sure what you mean, please feel free to include some of your code, but what I'm guessing is that you want horizontal <li> items on two lines, and the easiest way is probably to just create a new list;
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
</ul>
<!-- ending and starting a new list rather than using <br> -->
<ul>
<li>list item 4</li>
<li>list item 5</li>
<li>list item 6</li>
</ul>
css:
li { display: inline; }
Use float: left instead display: inline.
<style type="text/css">
<!--
ul.inline li{
float: left;
list-style: none;
}
//-->
</style>
...
<ul class="inline">
<li>A text</li>
<li>A text <br />More text</li>
<li>A text</li>
<li>A text</li>
<li>A text</li>
<li>A text</li>
</ul>
You may want to use a fixed width for those li's.
Result (Firefox 5):