Apply style to element, only if a certain element exists next to it

krinjxlzzv

New Member
I'm playing around with a lot of the new features in HTML5 and CSS3. I'm using the \[code\]<section>\[/code\] tag on several pages, but on ONE page I'm using an \[code\]<aside>\[/code\] tag that is preceeded by the \[code\]<section>\[/code\] tag.In the case that I have a \[code\]<section>\[/code\] immediately followed by an \[code\]<aside>\[/code\], I would like to apply a width to both and have the section float left, and the aside float right.Basically, if I have a \[code\]<section>\[/code\] and \[code\]<aside>\[/code\] I want the style to work like this:\[code\]section { width: 500px; float: left; padding: 8px;}aside { padding:8px; width:400px; float:right;}\[/code\]If I only have the \[code\]<section>\[/code\] I want it to be like:\[code\]section { padding: 8px;}\[/code\]Is there a way I can do this with either a conditional statement in CSS3, or a pseudo-class, without having to use javascript, custom classes, or separate CSS files?Thanks
 
Back
Top