kurt.santo Posted November 11, 2007 Share Posted November 11, 2007 If you want to have a listing with a heading which should look as the other list items (only in bold) how would you do this? Currently I simply place the heading in </li>, but wondered if there is a list heading or similar...Kurt Link to comment Share on other sites More sharing options...
jlhaslip Posted November 11, 2007 Share Posted November 11, 2007 code sample or a link might be nice. Link to comment Share on other sites More sharing options...
kurt.santo Posted November 11, 2007 Author Share Posted November 11, 2007 code sample or a link might be nice.Just after a normal lists as: <ul><li><h2>heading</h2></li><li>listing 1</li><li>listing 2</li></ul> My questions is more about the validity of using a list item as a heading. Somehow this seems not correct to me...Kurt Link to comment Share on other sites More sharing options...
Ingolme Posted November 11, 2007 Share Posted November 11, 2007 It's valid to put <h> tags inside <li> tags.But if you want all the first <li> tags of each list to have a different style you can try the CSS pseudo-class:li:first-child {font-weight: bold;}This style will be applied to every <li> that's a first element of a list. Link to comment Share on other sites More sharing options...
kurt.santo Posted November 11, 2007 Author Share Posted November 11, 2007 It's valid to put <h> tags inside <li> tags.But if you want all the first <li> tags of each list to have a different style you can try the CSS pseudo-class:li:first-child {font-weight: bold;}This style will be applied to every <li> that's a first element of a list.Thank you for your input! Have a go with given code...Kurt Link to comment Share on other sites More sharing options...
paynekj Posted November 13, 2007 Share Posted November 13, 2007 My personal preference is not to have a bullet point next to the heading because it isn't a member of the list, so I would modify the style to be:li:first-child {font-weight: bold;list-style: none;}However I usually use a definition list instead: <dl> <dt>Heading</dt> <dd>Item 1</dd> <dd>Item 2</dd></dl> and style the dt element:dt {font-weight: bold;}Kevin Link to comment Share on other sites More sharing options...
kurt.santo Posted November 13, 2007 Author Share Posted November 13, 2007 My personal preference is not to have a bullet point next to the heading because it isn't a member of the list, so I would modify the style to be:li:first-child {font-weight: bold;list-style: none;}However I usually use a definition list instead:<dl> <dt>Heading</dt> <dd>Item 1</dd> <dd>Item 2</dd></dl> and style the dt element:dt {font-weight: bold;}Kevin Cheers Kevin, Never really thought about using a definition list. Sounds like a great idea!Kurt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.